GET FREE VERSION GET THE PRO VERSION

Show tax exclusive prices for search results

Example of how to show tax exclusive prices for plugin search results and tax inclusive prices for all other products on the shop.

In this article

Overview

In this article we will cover one very specific topic - show tax exclusive prices for products inside search results and tax inclusive prices for products on all other shop places.

This article will be useful for all who display such prices including tax on their shops but for some reasons want to display net prices for search results.

Tax inclusive prices

Tax inclusive prices

Tax inclusive prices for search results

Tax inclusive prices for search results

How to show tax inclusive prices for WooCommerce products

First of all - let's cover how to display such tax inclusive prices for our shop products. If you are already familiar with this - just skip this chapter.

Steps to set tax inclusive prices:

1. Open WordPress admin page. Go to WooCommerce -> Settings -> Tax page.

2. On this page find Prices entered with tax option and set it to Yes, I will enter prices inclusive of tax.

'Prices entered with tax' option

'Prices entered with tax' option

3. Additionally on the same page set the value for Price display suffix option. For example - let's set it to inc. taxes. This will be helpful to let users know that the listed price already includes taxes.

'Price display suffix' option

'Price display suffix' option

4. Now open Standard rates page inside the current Tax tab. Here we need to set all taxes that must be applied to product prices. Set these options depending on your needs. In our example we set a VAT tax with value 23% that will apply for all users.

Setting up tax rates

Setting up tax rates

5. We are done. Now just check shop pages - prices for all your products must include specified taxes.

Product price including tax

Product price including tax

We finished setting up that standard WooCommerce option for tax inclusive prices. In the next chapter we will cover how to show tax exclusive prices for products inside plugin search results ( and leave all other prices unaffected ).

How to show tax exclusive prices for products search results

Now we need to show tax exclusive prices for products inside search results. To do this simply use the following code snippets:

add_filter( 'pre_option_woocommerce_tax_display_cart', 'aws_pre_option_tax', 10, 3 );
add_filter( 'pre_option_woocommerce_tax_display_shop', 'aws_pre_option_tax', 10, 3 );
function aws_pre_option_tax( $pre_option, $option, $default_value ) {
    if ( ( is_ajax() && $_REQUEST['action'] === 'aws_action' ) || ( isset( $_GET['type_aws'] ) && is_main_query() ) ) {
        $pre_option = 'excl';
    }
    return $pre_option;
}

add_filter( 'pre_option_woocommerce_price_display_suffix', 'aws_pre_option_suffix', 10, 3 );
function aws_pre_option_suffix( $pre_option, $option, $default_value ) {
    if ( ( is_ajax() && $_REQUEST['action'] === 'aws_action' ) || ( isset( $_GET['type_aws'] ) && is_main_query() ) ) {
        $pre_option = 'excl. taxes';
    }
    return $pre_option;
}

This code forces WooCommerce to show tax exclusive prices for products inside the plugin search results page and AJAX live results.

Additionally this code adds a new price suffix excl. taxes to inform users that they see prices without taxes. You can change this suffix value to any that you need.

You need to add this code snippets somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.

Product price without taxes

Product price without taxes