Please Check the Private content area
This topic has 5 replies, 3 voices, and was last updated 2 weeks, 5 days ago ago by Luca Rossi
Please Check the Private content area
Hi @Yasir Alam 8Theme,
Please try adding the following code under functions.php file locates in your child theme:
add_filter('woocommerce_format_sale_price', 'add_sale_price_percentage', 20, 3 );
function add_sale_price_percentage( $price, $regular_price, $sale_price ){
// Strip html tags and currency (we keep only the float number)
$regular_price = strip_tags( $regular_price );
$regular_price = (float) preg_replace('/[^0-9.]+/', '', $regular_price);
$sale_price = strip_tags( $sale_price );
$sale_price = (float) preg_replace('/[^0-9.]+/', '', $sale_price);
// Percentage text and calculation
$percentage = round( ( $regular_price - $sale_price ) / $regular_price * 100 );
// return on sale price range with "Save " and the discounted percentage
return $price . ' <span class="save-percent">' . $percentage . '% OFF</span>';
}
Hope it helps!
.
Video in the private area
Dear @Yasir Alam (8Theme),
We have reviewed the matter and noticed that the custom CSS has already been added, as shown in the following screenshot:
@Ronny: Kindly proceed to create a separate support ticket for further assistance.
Thank you for your attention to this matter.
Best regards,
The 8Theme Team
You must be logged in to reply to this topic.Log in/Sign up