• Resolved osmaq

    (@osmaq)


    price calculation with tax is disabled, On ajax request the plugin shows price including tax, I have made a custom archive template.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author annastaa

    (@annastaa)

    Hello Osmaq,

    Do you make the price adjustments in your custom archive template? Have you tried the Enable tax option in the Woocommerce > Settings > General tab of your WordPress admin, and then setting the Display prices in the shop to “Excluding tax” in the Tax > Tax options tab? Unless your theme customizes the native Woocommerce actions related to prices display, this should work for both the main archive loop and the filters’ AJAX mode out of the box, with no need for custom adjustments.

    Generally speaking, the filters’ AJAX mode uses the standard Woocommerce action hooks for product lists displays. Please check out the following Woocommerce files for the list of hooks (and corresponding functions) that you can use for the filters’ AJAX returns adjustments:

    …wp-content\plugins\woocommerce\includes\wc-template-hooks.php
    …wp-content\plugins\woocommerce\includes\wc-template-functions.php

    Thread Starter osmaq

    (@osmaq)

    Yes I, ve done all of the above, Tax is excluded from the shop page and I am using
    $product->get_regular_price() in my template I even changed the woocommerce loop and archive templates but nothing is changing

    Plugin Author annastaa

    (@annastaa)

    Hello again Osmaq,

    Custom templates aren’t used by the filters AJAX mode, you need to edit the hooked actions! You can do that in the functions.php of your child theme.

    But before turning to custom hooks and templates, I would once again advice you to try the native Woocommerce tax settings. I have just set the Display prices in the shop to “Excluding tax” on our test site that runs the Storefront theme just like your site, and everything works fine, AJAX or not! Perhaps the applied tax rate is outside your location detection? Try setting the Tax > Tax options > Calculate tax based on to “Shop base address” to see if the taxes start displaying properly this way.

    If the above doesn’t work, just to see if you can edit the price field of the filters’ AJAX returns, try adding the following code to the functions.php of your child theme (for testing purposes this could be done in the functions.php of the main theme too, just remember that any custom code gets erased during the theme updates):

    if ( ! function_exists( 'annasta_filters_ajax_price_adjustment' ) ) {
    	function annasta_filters_ajax_price_adjustment( $price, $product ) {
        $price = $product->get_regular_price();
    
        return $price;
    	}
    }
    
    if( wp_doing_ajax() && isset( $_REQUEST['awf_front'] ) && isset( $_GET['awf_action'] ) && 'filter' === $_GET['awf_action'] ) {
      add_filter( 'woocommerce_get_price_html', 'annasta_filters_ajax_price_adjustment', 10, 2 );
    }

    Please keep in mind that $product->get_regular_price() does NOT cover all kinds of products and prices (for example, the sale prices won’t be returned this way). For ideas see the native Woocommerce get_price_html functions.

    Plugin Author annastaa

    (@annastaa)

    Dear Osmaq,

    I will close this inactive thread in hope that some of the advice published here has proved to be useful for your case. You are always welcome to open a new topic if you have any further questions!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Tax excluded from shop page’ is closed to new replies.