Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce calculate totals

Tags:

woocommerce

I'm trying to display total cart value (including VAT) in the header of my site. However - if I try to use cart->get_cart_total() I get the price excluding VAT. If I try to use cart->get_totals() I get a value of 0 until I visit the cart page - then it shows the correct value (even if I surf to other pages).

Ok, so I tried to run cart->calculate_totals() before fetching the cart->get_totals() but it seems to reset the value... It still works fine on the cart page though.

Could someone please help me here? Thanks

like image 355
Joakim Carlsten Avatar asked Sep 03 '25 03:09

Joakim Carlsten


1 Answers

I managed to get the desired result by using cart->get_cart_subtotal().

Now I just want to remove the "(incl. tax)" that gets amended to the result.

like image 164
Joakim Carlsten Avatar answered Sep 06 '25 00:09

Joakim Carlsten