Title: Save amount text
Last modified: March 3, 2021

---

# Save amount text

 *  [freddyee](https://wordpress.org/support/users/freddyee/)
 * (@freddyee)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/save-amount-text/)
 * Hi
 * How to add the text “Save amount: X” ?? , like this one on cart page (the text
   is circled)
    [https://snipboard.io/AcRf7r.jpg](https://snipboard.io/AcRf7r.jpg)
 * and this one in the cart window (the text is circled) :
    [https://snipboard.io/KtY9Xp.jpg](https://snipboard.io/KtY9Xp.jpg)
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fsave-amount-text%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [Bonn](https://wordpress.org/support/users/bonnlevelup/)
 * (@bonnlevelup)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14132117)
 * Hi,
 * Sorry, there isn’t a built-in function for this.
 * There may be a plugin that offers this kind of functionality, but I’m not sure
   of one.
 * I found this tutorial, maybe this can help you: [https://www.businessbloomer.com/woocommerce-display-total-discount-savings-cart/](https://www.businessbloomer.com/woocommerce-display-total-discount-savings-cart/)
 * Let us know if there’s something else we can assist with.
 * Regards,
    Bonn
 *  Thread Starter [freddyee](https://wordpress.org/support/users/freddyee/)
 * (@freddyee)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14148297)
 * yeah that code worked, thanks.
    what about this one in the cart window (the text
   is circled) : [https://snipboard.io/KtY9Xp.jpg](https://snipboard.io/KtY9Xp.jpg)
 * How can that be done ?
 *  Thread Starter [freddyee](https://wordpress.org/support/users/freddyee/)
 * (@freddyee)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14163625)
 * Hello ?
 *  [Ben Ritner – Kadence WP](https://wordpress.org/support/users/britner/)
 * (@britner)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14165111)
 * Hey [@freddyee](https://wordpress.org/support/users/freddyee/)
 * You would need to modify the code to fit your needs. The theme doesn’t have options
   for this.
 * If you look at woocommerce files there is a hook for the mini cart: [https://github.com/woocommerce/woocommerce/blob/trunk/templates/cart/mini-cart.php#L84](https://github.com/woocommerce/woocommerce/blob/trunk/templates/cart/mini-cart.php#L84)
 * Using that to hook in the function posted above would have that showing in the
   popout mini cart.
 * Ben
 *  Thread Starter [freddyee](https://wordpress.org/support/users/freddyee/)
 * (@freddyee)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14169308)
 * well the code now would be:
 *     ```
       add_action( 'woocommerce_widget_shopping_cart_before_total', 'bbloomer_show_total_discount_cart_checkout', 9999 );
       add_action( 'woocommerce_widget_shopping_cart_before_total', 'bbloomer_show_total_discount_cart_checkout', 9999 );
   
       function bbloomer_show_total_discount_cart_checkout() {
   
          $discount_total = 0;
   
          foreach ( WC()->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><th>You Saved</th><td data-title="You Saved">' . wc_price( $discount_total + WC()->cart->get_discount_total() ) .'</td></tr>';
           }
   
       }
       ```
   
 * But I’m having problems with this, function bbloomer_show_total_discount_cart_checkout(),
   since it’s already declared.
    -  This reply was modified 5 years, 2 months ago by [freddyee](https://wordpress.org/support/users/freddyee/).
 *  Thread Starter [freddyee](https://wordpress.org/support/users/freddyee/)
 * (@freddyee)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14185142)
 * Hello?
 *  [hannah](https://wordpress.org/support/users/hannahritner/)
 * (@hannahritner)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14186659)
 * Hey [@freddyee](https://wordpress.org/support/users/freddyee/),
    Apologies for
   the delay. Where else is this code being declared? Are you able to modify it?
   Your question goes a bit beyond what free support we can offer. But we would 
   love to get you set up well!
 * Kindly,
    Hannah
 *  [Ben Ritner – Kadence WP](https://wordpress.org/support/users/britner/)
 * (@britner)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14187065)
 * You need to change the function name if you just want to duplicate it, bbloomer_show_total_discount_cart_checkout
   can just become bbloomer_show_total_discount_cart_checkout2 if you want.
 * I suggest hiring a developer if you need a lot of custom work done so that you
   can make sure this is coded right and won’t create problems for you down the 
   road.
 * Ben
 *  Thread Starter [freddyee](https://wordpress.org/support/users/freddyee/)
 * (@freddyee)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14187077)
 * Thank you very much Hannah
 * the code I previously used was:
 *     ```
       add_action( 'woocommerce_cart_totals_after_order_total', 'bbloomer_show_total_discount_cart_checkout', 9999 );
       add_action( 'woocommerce_review_order_after_order_total', 'bbloomer_show_total_discount_cart_checkout', 9999 );
   
       function bbloomer_show_total_discount_cart_checkout() {
   
          $discount_total = 0;
   
          foreach ( WC()->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><th>Tú ahorras</th><td data-title="Tú ahorras">' . wc_price( $discount_total + WC()->cart->get_discount_total() ) .'</td></tr>';
           }
   
       }
       ```
   
 * This code is in the functions.php file.
    I want to change it to make appear the“
   you save” text in the mini cart. I was using the woocommerce_widget_shopping_cart_before_total
   hook
 *  [Ben Ritner – Kadence WP](https://wordpress.org/support/users/britner/)
 * (@britner)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14218749)
 * Hey [@freddyee](https://wordpress.org/support/users/freddyee/)
 * Just want to make sure you saw my post as I posted just before you and answered
   this.
 * Ben

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Save amount text’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/kadence/1.5.0/screenshot.png)
 * Kadence
 * [Support Threads](https://wordpress.org/support/theme/kadence/)
 * [Active Topics](https://wordpress.org/support/theme/kadence/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/kadence/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/kadence/reviews/)

 * 10 replies
 * 4 participants
 * Last reply from: [Ben Ritner – Kadence WP](https://wordpress.org/support/users/britner/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/save-amount-text/#post-14218749)
 * Status: not resolved