Woocommerce Subtotal Only Numbers

I’m trying to get the float value from WooCommerce’s cart

don’t want to parse this function:
$woocommerce->cart->get_cart_subtotal();

Read More

is there any way to get clean subtotal from the woocommerce’s cart?

it suppose to be really simple, but i’m stuck 🙂

Related posts

1 comment

  1. Borrowing from the cart class’s get_cart_subtotal() method, I believe you could do something like:

    if ( WC()->cart->tax_display_cart == 'excl' ) {
    
        $cart_subtotal = WC()->cart->subtotal_ex_tax;
    
    } else {
    
        $cart_subtotal = WC()->cart->subtotal;
    
    }
    

    This assumes that you aren’t doing compounded tax. The unformatted subtotals seem to be stored as class variables.

Comments are closed.