phpwordpresswoocommercesubtotal

Woocommerce Exclude Tax from Checkout Subtotal


I am using the hook below to currently exclude tax from the subtotal on the shopping cart. But changing out cart with checkout is not in the docs.

How can I exclude the tax from the Checkout page Subtotal?

Thanks.

add_filter( 'woocommerce_cart_product_subtotal', 'exclude_tax_cart_product_subtotal', 15, 4 );
function exclude_tax_cart_product_subtotal( $product_subtotal, $_product, $quantity, $object ) {
    $row_price  = $_product->get_price_excluding_tax( $quantity );
    $ex_tax = wc_price( $row_price );
    return $ex_tax;
}

Solution

  • 'woocommerce_cart_subtotal' filter modified the subtotal output in checkout page.

    add_filter( 'woocommerce_cart_subtotal', 'exclude_tax_subtotal', 15, 4 );
    function exclude_tax_subtotal( $product_subtotal ) {
        // do whatever you want to do
        return $product_subtotal;
    }