I was wondering if there’s a way to display the discount price with the original price crossed out when a product is on sale? So I wrote a code to show the price in order summary at the checkout page and cart page.

It is straightforward. WooCommerce provides a filter for item subtotal, and we are going to use that filter. In the function, we will check if the product is on sale, will multiply regular price with the item quantity, and then append it to the total amount. Isn’t it simple?
/**
* @snippet WooCommerce: Display Product Discount in Order Summary @ Checkout, Cart
* @author Sandesh Jangam
* @donate $7 https://www.paypal.me/SandeshJangam/7
*/
add_filter( 'woocommerce_cart_item_subtotal', 'ts_show_product_discount_order_summary', 10, 3 );
function ts_show_product_discount_order_summary( $total, $cart_item, $cart_item_key ) {
//Get product object
$_product = $cart_item['data'];
//Check if sale price is not empty
if( '' !== $_product->get_sale_price() ) {
//Get regular price of all quantities
$regular_price = $_product->get_regular_price() * $cart_item['quantity'];
//Prepend the crossed out regular price to actual price
$total = '<span style="text-decoration: line-through; opacity: 0.5; padding-right: 5px;">' . wc_price( $regular_price ) . '</span>' . $total;
}
// Return the html
return $total;
}
I hope this helps you.
8 thoughts on “WooCommerce: Display Product Discount in Order Summary @ Checkout”
It saved my time.
Thank you!
I am glad that it works for you.
Well done, but the strike out price only show regular price excluding tax which can be confusing. The strikeout price excluding tax is lower than the sales price including tax. Do you have a fix for that?
Yeah, quite confusing. It is possible to show the tax as well but it is custom work for me. Please contact me to get a quote. Thanks.
not working in my spacework
Your theme must have heavily modified the WooCommerce templates. Please try to contact theme author or contact me to get a quote. Thanks.
hi,
I want to show regular price of item along with sale price in my invoice. Can you guide me plz. (Currently invoice fetches data from woocommerce order which doesn’t contain regular_price when sale_price is triggered).I m trying to learn some coding.
thx
Great Work! Thank you