This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Show prices including VAT

#38093
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

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.

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;
}