I have a wp condition which displays me the price of the products.
if (empty($sales_price)) {
echo '<span class="price"><span class="woocommerce-Price-amount amount">'.$regular_price.' <span class="woocommerce-Price-currencySymbol">zł</span></span> </span>';
} else {
echo '<span class="price"><del><span class="woocommerce-Price-amount amount">'.$regular_price.' <span class="woocommerce-Price-currencySymbol">zł</span></span></del> <ins><span class="woocommerce-Price-amount amount">'.$sales_price.' <span class="woocommerce-Price-currencySymbol">zł</span></span></ins></span>';
}
Each product has several variations and different prices. My problem is that prices do not change when changing options in the select box. I tried to add JS in different ways but nothing wanted to reload my price. How can I solve it?
Well, PHP + JS should do the trick, you can locate and set a php script to respond to AJAX Request on WP. Though, I'd link you an answer i gave a few time ago for a different question, but it should work for you: https://stackoverflow.com/a/45490613/6654533
What you're supposed to do with this method is the following:
change
event is fired and send an AJAX POST request as shown by the answer posted above; Hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.