Search code examples
woocommercediscount

Woocommerce - Get Discounted product regular price WITHOUT tax


My following code allows a product that is on sale to display the regular price followed by the discounted price. The discounted price is excluding tax but the regular price is set to include tax (as per Woocommerce settings), as only this product type needs to show '+tax'.

How can I get $product->regular_price; to be displayed excluding tax?

                if( $product->is_on_sale() ) {
                    echo '<div style="text-decoration: line-through" class="original_price">£';
                    echo $product->regular_price;
                    echo ' </div>';
                }
                echo wc_price( wc_get_price_excluding_tax( $product ) );
                if ( $product->is_taxable() ) {
                    echo ' +VAT';
                }

Solution

  • You can change the following line

    echo $product->regular_price;
    

    To

    echo wc_get_price_excluding_tax( $product, array(
        'price' => $product->regular_price
    );