Handle price suffix with price for product button check

This commit is contained in:
Alex P 2023-03-07 16:20:01 +02:00
parent 91c39fdef2
commit 3d096fb2ad
No known key found for this signature in database
GPG key ID: 54487A734A204D71

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;
},