Show Total Discount in WooCommerce Cart & Checkout

To show customers the total discount applied to their order in the WooCommerce cart and checkout, you can use the woocommerce_cart_totals_before_order_total and woocommerce_review_order_before_order_total hooks.

Step 1: Open your active theme’s functions.php file.

Step 2: Add the following code:

// Display total savings in cart and checkout
function display_total_discount() {
    $total_discount = WC()->cart->get_cart_discount_total();

    if ($total_discount > 0) {
        $formatted_discount = wc_price($total_discount);
        echo '<tr class="total-discount"><th>' . __('Total Discount', 'your-text-domain') . '</th><td data-title="' . __('Total Discount', 'your-text-domain') . '">' . $formatted_discount . '</td></tr>';
    }
}
add_action('woocommerce_cart_totals_before_order_total', 'display_total_discount');
add_action('woocommerce_review_order_before_order_total', 'display_total_discount');

Step 3: Save and upload the file back to your server.

Now, the cart and checkout tables will display a new row labeled “Total Discount” that reflects the applied discount amount.

Make sure to style the output to match your theme, and change the 'your-text-domain' to your theme or plugin’s actual text domain.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.