Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Show prices including VAT
This topic contains 4 replies, has 2 voices, and was last updated by andreasesp 7 months, 3 weeks ago.
- AuthorPosts
- June 17, 2022 at 9:23 am #38069
Hello, I’ve followed the steps on this site: https://documentation.ajaxsearchpro.com/advanced-options/advanced-title-and-description-fields to add regular price and sale price on products. But the prices that are showing is without VAT. How can I make them show including VAT?
June 17, 2022 at 1:32 pm #38076Hi,
Instead of the “_price” field, use the “_tax_price”, that should do the trick 🙂 I have corrected the documentation as well.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 17, 2022 at 1:34 pm #38077Thanks 😊 But is there an option for sale price with tax as well?
June 20, 2022 at 9:05 am #38093Hi,
That may need a custom code, but I could not find the proper method on WooCommerce documentation on how to get that price exactly. I can only assume it will work.
Use the
{_tax_sale_price}
variable, and also the custom code below.Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
Best,add_filter('asp_results', 'asp_results_custom_variable', 10, 1); function custom_asp_redirect_url($results) { foreach ( $results as $k => &$r ) { if ( $r->post_type == 'product' || $r->post_type == 'product_variation' ) { $product = wc_get_product( $r->id ); $r->title = str_replace( '{_tax_sale_price}', wc_get_price_including_tax( $product, array( 'price' => $product->get_sale_price() ), $r->title ); $r->content = str_replace( '{_tax_sale_price}', wc_get_price_including_tax( $product, array( 'price' => $product->get_sale_price() ), $r->content ); } } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 20, 2022 at 9:17 am #38096Thanks, I’ll try 😊
- AuthorPosts
You must be logged in to reply to this topic.