Get total cart woocommerce

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:

Read More
app = $20.00
app2 = 0

and the cart is of $20.00
Thanks.

Related posts

2 comments

  1. 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’

  2. You can try

    global $woocommerce;
    $Cart = WC()->cart->subtotal;
    echo "CART : " . $Cart;
    

Comments are closed.