Reputation: 67
I need to have the import of cart in woocommerce. But i need the number without wc_price(). This is my code:
global $woocommerce;
$app=$woocommerce->cart->get_cart_total();
$app2=$woocommerce->cart->total;
and it results:
app = $20.00
app2 = 0
and the cart is of $20.00 Thanks.
Upvotes: 3
Views: 3303
Reputation: 16
You can try
global $woocommerce;
$Cart = WC()->cart->subtotal;
echo "CART : " . $Cart;
Upvotes: 0
Reputation: 733
You try
$app= (float) preg_replace( '/[^0-9\.]/', '', $woocommerce->cart->get_cart_total() );
Or
$app = str_replace('$','',$woocommerce->cart->get_cart_total() );
the solution depends on the type of currency that is occupied in this case the euro occupied, so we had to replace the euro in htmlentities as shown here
str_replace ( '& euro;', '', $ woocommerce-> cart-> get_cart_total ());
Note: trim '& euro'
Upvotes: 1