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

    (@bonnlevelup)

    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/

    Let us know if there’s something else we can assist with.

    Regards,
    Bonn

    Thread Starter freddyee

    (@freddyee)

    yeah that code worked, thanks.
    what about this one in the cart window (the text is circled) :
    https://snipboard.io/KtY9Xp.jpg

    How can that be done ?

    Thread Starter freddyee

    (@freddyee)

    Hello ?

    Hey @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

    Using that to hook in the function posted above would have that showing in the popout mini cart.

    Ben

    Thread Starter freddyee

    (@freddyee)

    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 3 years, 7 months ago by freddyee.
    Thread Starter freddyee

    (@freddyee)

    Hello?

    hannah

    (@hannahritner)

    Hey @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

    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

    (@freddyee)

    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

    Hey @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.