Product Archive, Product Page

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;
}

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER