I have a WooCommerce store and am using the ‘Advanced Dynamic Pricing for Woocommerce’ plugin. I need to use this plugin because I have discount structures set up
Percentage discounts have been applied to all products in store. The original price is crossed out with the new price next to it.
enter image description here
I want to display a suffix next to the new price that says ‘inc VAT’ to indicate that the price is inclusive of VAT.
I have tried this code which seems to work on products that don’t have discounts applied but not on discounted products.
add_filter( 'woocommerce_get_price_html', 'custom_price_suffix', 100, 2 );
function custom_price_suffix( $price, $product ){
$price = $price . 'inc VAT' ;
return apply_filters( 'woocommerce_get_price', $price );}
Anyone know how I can achieve this?
The generated HTML code looks like this:
<div class="woosg-price">
<div class="woosg-price-ori">
<del>
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">£</span>262.00</span>
</del>
<ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-
currencySymbol">£</span>117.90</span></ins>
</div>
<div class="woosg-price-new"></div>
</div>
2
Answers
You Can add Suffix using the below filter.
Or You can use below code as well.
You can add suffix from the WooCommerce settings using the below steps.
You can use
woocommerce_get_price_suffix
dedicated hook, targeting on sale products like:or maybe this instead (because of Advanced Dynamic Pricing for Woocommerce plugin):
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Related: