Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More โShow total discount amount in WooCommerce cart and checkout pages using custom hooks. Add discount row to order totals table for customer transparency, helping shoppers see total savings and improving checkout experience with clear pricing.
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. 
Search our archives or reach out to our team for solutions and expert advice.