From 3d096fb2ad9846cc20944b226f8aab80c4998bc2 Mon Sep 17 00:00:00 2001 From: Alex P Date: Tue, 7 Mar 2023 16:20:01 +0200 Subject: [PATCH] Handle price suffix with price for product button check --- .../js/modules/ContextBootstrap/SingleProductBootstap.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js index 6c0a03283..a36c1d408 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js @@ -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; },