fja3omega
fja3omega

Reputation: 222

How to get WooCommerce cart subtotal value?

I am currently trying to make an if else check in the checkout of a WooCommerce site.

I need to know if the total is greater or less than 100, so that it will say "You need to call to negotiate a shipping fee".

The code:

$woocommerce->cart->get_cart_total() 

shows the value, but adds HTML content.

I need only the value itself.

Upvotes: 1

Views: 3901

Answers (1)

fja3omega
fja3omega

Reputation: 222

I kind of found out how to do this the hard way.

Reference

global $woocommerce;
$subtotal = $woocommerce->cart->get_subtotal();
$subtax = $woocommerce->cart->get_subtotal_tax();
$subtotaltax = $subtotal+$subtax;

echo with $subtotaltax shows the value with the tax added.

Upvotes: 5

Related Questions