WC_Cart::get_cart_subtotal PHP Method

get_cart_subtotal() public method

Gets the sub total (after calculation).
public get_cart_subtotal ( boolean $compound = false ) : string
$compound boolean whether to include compound taxes
return string formatted price
    public function get_cart_subtotal($compound = false)
    {
        // If the cart has compound tax, we want to show the subtotal as
        // cart + shipping + non-compound taxes (after discount)
        if ($compound) {
            $cart_subtotal = wc_price($this->cart_contents_total + $this->shipping_total + $this->get_taxes_total(false, false));
            // Otherwise we show cart items totals only (before discount)
        } else {
            // Display varies depending on settings
            if ('excl' === $this->tax_display_cart) {
                $cart_subtotal = wc_price($this->subtotal_ex_tax);
                if ($this->tax_total > 0 && $this->prices_include_tax) {
                    $cart_subtotal .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
                }
            } else {
                $cart_subtotal = wc_price($this->subtotal);
                if ($this->tax_total > 0 && !$this->prices_include_tax) {
                    $cart_subtotal .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
                }
            }
        }
        return apply_filters('woocommerce_cart_subtotal', $cart_subtotal, $compound, $this);
    }
WC_Cart