1

I've inherited a custom built Woocommerce site and am having to make some upgrades but are getting a little stuck.

I can show the cart total before taxes:

WC()->cart->get_cart_total();

I can show the taxes to be applied:

WC()->cart->get_cart_contents_tax();

And the final with the taxes applied:

WC()->cart->get_cart_subtotal();

But I cannot find anyway to show the flat rate shipping I have and also the cart total with the shipping cost applied.

I only have one shipping item which is active, flat rate, with all continents applied to make it global. I'm logged in with an address registered but it doesn't display it.

I have tried multiple options including...

WC()->cart->calculate_totals();
WC()->cart->calculate_shipping();
$packages = WC()->shipping->get_packages();

...but still no shipping price or cart total with shipping.

1 Answers1

1

To extract shipping cost, I would go like this, using get_cart_shipping_total:

$shipping_cost = WC()->cart->get_cart_shipping_total();

Have a try.

jjj
  • 965
  • 8
  • 23