This topic has 3 replies, 2 voices, and was last updated 10 years, 7 months ago ago by Jack Richardson
Hi
is it possible to display the discount percentage on a product?
fond the answer my self 🙂
add to function.php
// Add save percent next to sale item prices.
add_filter( ‘woocommerce_sale_price_html’, ‘woocommerce_custom_sales_price’, 10, 2 );
function woocommerce_custom_sales_price( $price, $product ) {
$percentage = round( ( ( $product->regular_price – $product->sale_price ) / $product->regular_price ) * 100 );
return $price . sprintf( __(‘ Save %s’, ‘woocommerce’ ), $percentage . ‘%’ );
}
Hello,
That’s good to hear!
Please if you have any questions feel free to contact us.
Regards,
Jack Richardson
The issue related to '‘show discount in percentage’' has been successfully resolved, and the topic is now closed for further responses