Show Total Savings on Cart and Checkout Page in WooCommerce

Do you offer a discount or coupons code on your woocommerce store and want to show total savings to your customers?

show total savings

Guess What,

I have a solution for you.

How to Show Total Savings on Cart and Checkout Page

In order to show savings after all the discounts and coupons are applied, You need to add the following code in your theme’s functions.php file. After you add the below code snippet customers will see their total savings under the Total Amount.

function wc_discount_total() {
   global $woocommerce;
    $discount_total = 0;
      
    foreach ( $woocommerce->cart->get_cart() as $cart_item_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'];
        $discount_total += $discount;
        }
    }        
    if ( $discount_total > 0 ) {
    echo '<tr class="cart-discount">
    <th>'. __( 'Your Savings', 'woocommerce' ) .'</th>
    <td data-title=" '. __( 'You Saved', 'woocommerce' ) .' ">'
    . wc_price( $discount_total + $woocommerce->cart->discount_cart ) .'</td>
    </tr>';
    }
}
add_action( 'woocommerce_cart_totals_after_order_total', 'wc_discount_total', 99);
add_action( 'woocommerce_review_order_after_order_total', 'wc_discount_total', 99);

Why You should show total Savings to Customers

Most likely you offer some kind of discount coupons or probably the just lowered price or put some items on sale and,

when the customer see how much money they are saving it gives them confidence that they are getting a good deal.

A study conducted by Dr. Paul J. Zak, a professor of neuroeconomics at Claremont Graduate University in Sothern California found out that brands and retailers benefit from the fact that coupon users shop more frequently and have bigger baskets sizes. in addition to that coupons actually physically affect our bodies; they make us feel good.

So, If customers are not using coupons but still see how much money they are savings after you lower prices on inventory triggers the same response.

WHERE TO ADD THIS CODE?

You need to paste the above code snippet into your theme’s functions.php file. Which you can find in Dashboard >> Appearance >> Editor

OR

You can access the file via FTP. Just go to directory where you Install WordPress >> Wp-Content folder >> Themes >> Your active theme folder >> functions.php

If you think it was valuable in teaching shows how Total Savings on Cart and Checkout Page, Please support us on TwitterFacebook or Google plus.

Have any question? Don’t forget to leave a comment below.

Leave a Reply

  Subscribe  
Notify of