WooCommerce Show Fixed Amount Savings On Sale Products

To display a fixed amount savings on sale products in WooCommerce, you can use the following code snippet. This code should be added to your theme’s functions.php file or in a custom 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:	https://wpproblog.com
 */

//For Simple Products Display Fixed Saving Amount On Sale
add_filter( 'woocommerce_get_price_html', 'wpproblog_display_fixed_amount_savings_on_sale_simple_products', 10, 2 );
function wpproblog_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 Display Fixed Saving Amount On Sale
add_filter( 'woocommerce_available_variation', 'wpproblog_display_fixed_amount_savings_on_sale_variable_products', 10, 3 );
function wpproblog_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;
}

Final Output:

This code adds a filter to modify the sale price display. It calculates the savings by subtracting the regular price from the sale price and formats it using wc_price() function. Finally, it appends the savings amount to the price display using the element with a class of savings.

After adding the code, the fixed amount savings should be displayed on the sale products in your WooCommerce store. You can modify the CSS styles for the .savings class to customize the appearance as per your needs.