0

I have functionality that build on total based amount on cart page in WooCommerce. I get cart items total value with function:

WC()->cart->subtotal() - WC()->cart->get_discount_total();

Problem is: If user enter coupon or other discount subtotal() still give same result (without coupons inside). I noticed if i refresh page, sum is working perfectly. How I can make this change to be working on ajax cart refresh?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • 1
    It's surprising, as far as i know, ```update cart section``` and ```coupon code section``` are using ```ajax``` by default. If you've developed your theme from scratch, then it might be the issue of caching between the pages. It's a common issue for custom built themes that use browser caching to speed up the loading of a page and not updating the elements on a page. – Ruvee Jan 30 '21 at 14:09
  • 1
    You need to Ajaxify this totals the same way as [this thread](https://stackoverflow.com/questions/51123903/ajaxify-header-cart-items-count-in-woocommerce/51126271#51126271) – LoicTheAztec Jan 30 '21 at 14:33
  • 1
    @LoicTheAztec Nice! The ```jquery``` part did the trick for me!!! Thank you. – Ruvee Jan 30 '21 at 16:38
  • 1
    So you should post that as an answer to your own question with a little explanation may be *(useful for the community)* – LoicTheAztec Jan 30 '21 at 16:42
  • @LoicTheAztec Thanks, i will try. Will i need to enter specific id header for making it? – Vladimir Kyatipov Jan 30 '21 at 20:47

0 Answers0