Merge pull request #1234 from woocommerce/PCP-1483-price-suffix

Handle price suffix with price for product button check
This commit is contained in:
Emili Castells 2023-03-16 15:12:58 +01:00 committed by GitHub
commit 9283c28bd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,8 +69,13 @@ class SingleProductBootstap {
() => {
const priceEl = document.querySelector('.product .woocommerce-Price-amount');
// variable products show price like 10.00 - 20.00 here
if (priceEl && priceEl.parentElement.querySelectorAll('.woocommerce-Price-amount').length === 1) {
return priceEl.innerText;
// but the second price also can be the suffix with the price incl/excl tax
if (priceEl) {
const allPriceElements = Array.from(priceEl.parentElement.querySelectorAll('.woocommerce-Price-amount'))
.filter(el => !el.parentElement.classList.contains('woocommerce-price-suffix'));
if (allPriceElements.length === 1) {
return priceEl.innerText;
}
}
return null;
},