WooCommerce Checkout: Display Regular price & Sale Price

One thing that has always irritated me about the WooCommerce Checkout Process; It doesn’t display Regular Price & Sale Price in the Cart and Checkout pages.

The Problem:

By default, WooCommerce only displays the sale price of a product in the cart and checkout pages. This can sometimes be confusing for customers, especially if they want to compare the original price to the discounted price. It can also be a problem when the cart calculates larger savings than what is shown in the cart. All in all, it’s absence can be a real issue.

The Solution:

To address this issue, the below code snippet will fix the WooCommerce checkout to display both the regular and sale prices on the cart and checkout pages. The regular price will be crossed out and when viewing the “You Saved” section in the cart, it will appear to be calculated correctly since the regular price is now displayed.

Tested as working in current versions of WordPress and WooCommerce 11/11/24

// Show regular price and sale price in WooCommerce Checkout and Cart -TAB

function show_sale_price_at_checkout( $subtotal, $cart_item, $cart_item_key ) {
    $product = $cart_item['data'];
    $quantity = $cart_item['quantity'];

    if ( ! $product || ! $product->is_on_sale() ) {
        return $subtotal;
    }

    // Calculate regular and sale prices, considering tax and quantity
    $regular_price = wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price(), 'qty' => $quantity ) );
    $sale_price = wc_get_price_to_display( $product, array( 'price' => $product->get_sale_price(), 'qty' => $quantity ) );

    // Format the sale price with crossed-out regular price
    $price = wc_format_sale_price( $regular_price, $sale_price ) . $product->get_price_suffix();

    // Add tax suffix if applicable
    if ( $product->is_taxable() && WC()->cart->tax_total > 0 ) {
        $suffix = WC()->cart->prices_include_tax
            ? WC()->countries->inc_tax_or_vat()
            : WC()->countries->ex_tax_or_vat();

        $price .= ' ' . $suffix;
    }

    return $price;
}

add_filter( 'woocommerce_cart_item_subtotal', 'show_sale_price_at_checkout', 10, 3 );

How do I use this code snippet?

If you have a child theme (and only if you have a child theme), you can paste this code snippet into your functions.php file). You can also add the code via a code snippet plugin like WPCode. Such plugins can be a convenient way to organize your snippets and enable or disable them individually.

Item added to cart.
0 items - $0.00