WooCommerce Show Percentage Saving Amount On Sale Product

WooCommerce sale product showing percentage saving


There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

This snippet allows you to display the percentage saving amount on sale products on the single product template and on the loop items.

 * Snippet Name:	WooCommerce Display Percentage Saving Amount On Sale Products
 * Snippet Author:	ecommercehints.com

// Simple Products
add_filter( 'woocommerce_get_price_html', 'ecommercehints_display_percentage_savings_amount_on_sale_simple_products', 10, 2 );
function ecommercehints_display_percentage_savings_amount_on_sale_simple_products( $price, $product ) {
    if ( $product->is_on_sale() && $product->is_type( 'simple' ) ) {
        $regular_price = $product->get_regular_price();
        $sale_price = $product->get_sale_price();
		$savings_calculation = $sale_price * 100 / $regular_price;
		$savings_total = 100 - $savings_calculation;
        $price .= '<br><small>You save ' . round($savings_total) . '%</small>';
    return $price;

// Variable Products (shows when variations have been selected)
add_filter( 'woocommerce_available_variation', 'ecommercehints_display_percentage_savings_amount_on_sale_variable_products', 10, 3 );
function ecommercehints_display_percentage_savings_amount_on_sale_variable_products( $data, $product, $variation ) {
    if( $variation->is_on_sale() ) {
        $savings_amount = $data['display_regular_price'] - $data['display_price'];
        $percentage_amount = round( $saved_amount / $data['display_regular_price'] * 100 );
        $data['price_html'] .= 'You save ' . $percentage_amount.  '%';
    return $data;
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers