WooCommerce Show Fixed Amount Savings On Sale Products

WooCommerce sale product showing fixed amount savings

Pre-Requisites

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 fixed amount monetary value the customer is saving when a product is on sale.

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

// Simple Products
add_filter( 'woocommerce_get_price_html', 'ecommercehints_display_fixed_amount_savings_on_sale_simple_products', 10, 2 );
function ecommercehints_display_fixed_amount_savings_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 = $regular_price - $sale_price;
        $price .= '<br><small>You save ' . wc_price($savings) . '!</small>';
	}
    return $price;
}

// Variations (appears once variations have been selected)
add_filter( 'woocommerce_available_variation', 'ecommercehints_display_fixed_amount_savings_on_sale_variable_products', 10, 3 );
function ecommercehints_display_fixed_amount_savings_on_sale_variable_products( $data, $product, $variation ) {
    if( $variation->is_on_sale() ) {
        $savings_amount = $data['display_regular_price'] - $data['display_price'];
        $data['price_html'] .= 'You save' . wc_price($savings_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