Show Sale Percentage In WooCommerce

Share Now

Share on facebook
Share on pinterest
Share on twitter
Share on linkedin
Share on email
<?php 
$price = get_post_meta( get_the_ID(), '_price', true );
$regular_price = get_post_meta( get_the_ID(), '_regular_price', true );
$sale_price = get_post_meta( get_the_ID(), '_sale_price', true );

// "Saving Percentage" calculation and formatting
$precision = 1; // Max number of decimals
$saving_percentage = round( 100 - ( $sale_price / $regular_price * 100 ), 1 ) . '%';
?>
Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert