How can I get the cart total/total_ex_tax as float number?
I looked for, but all answers are like:
a) Ugly usage reg_exp (For example, what if we will be to use ',' instead '.'?):
global $woocommerce;
$amount = floatval( preg_replace( '#[^\d.]#', '', $woocommerce->cart->get_cart_total() ) );
b) Direct access to class properties (which can be to change in future; and not the OOP method). It works, but it's a wrong way:
global $woocommerce;
echo $woocommerce->subtotal;
echo $woocommerce->subtotal_ex_tax;
echo $woocommerce->total;
echo $woocommerce->total_ex_tax;
echo $woocommerce->cart_contents_total;
I want to get normal API something like this:
$wc = WC();
echo $wc->cart->get_total_as_number();
echo $wc->cart->get_total_ex_tax_as_number();