This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

How to Display Discount at WooCommerce Cart Page

Updated on May 26, 2021

2 Min Read

This is the season of discounts. Every WooCommerce store is offering discounts of all description to take advantage of the holiday craze.

WooCommerce Discount Cart

However, displaying the total price and the discount could pose some difficulties for WooCommerce Single Product pages and product listings. In many cases, the price breakdown is present at the bottom of the page. However, the developers could easily present an improved breakdown that displays the price after discounts and the discounted amount.

The following code snippet will add this functionality to the WooCommerce stores. It is important to note that with appropriate modifications, this snippet could be used to display other information such as:

  • Total Sales
  • Total Orders
  • Total of All Shipping Costs
  • Total of All Discounts Used
  • Total of All Items Ordered
  • Total Sales Per Item

Put the following snippet in the functions.php:

function cw_discount() {
   global $woocommerce;
   $cw_discount = 0;
   foreach ( $woocommerce->cart->get_cart() as $cw_cart_key => $values) {
       $_product = $values['data'];
       if ( $_product->is_on_sale() ) {
            $regular_price = $_product->get_regular_price();
            $sale_price = $_product->get_sale_price();
            $discount = ($regular_price - $sale_price) * $values['quantity'];
            $cw_discount += $discount;
   if ( $cw_discount > 0 ) {
        echo '<tr class="cart-discount">
    <th>'. __( 'Secure', 'woocommerce' ) .'</th>
    <td data-title=" '. __( 'Secure', 'woocommerce' ) .' ">'
            . wc_price( $cw_discount + $woocommerce->cart->discount_cart ) .'</td>


add_action( 'woocommerce_cart_totals_after_order_total', 'cw_discount');
add_action( 'woocommerce_review_order_after_order_total', 'cw_discount');

Here is is how the output of the snippet would look like. As you could see, the discount is shown on a separate line.

Secure cart


In this article I have discussed  how to display total discount at WooCommerce cart page. with some modifications, you could display several other price attributes as well. If you need help with the code, do leave a comment below.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Great performance for the price, and plenty of control”

Sean P [SMB Owner]

Owais Alam

is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform and a seasoned PHP developer. He loves to develop all sorts of websites on WordPress and is in love with WooCommerce in particular. You can email him at [email protected]


Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!