WooCommerce Smart Sale Badge
"up to" only if different amounts (3 posts)

  1. Apfelbiss
    Posted 2 years ago #


    I changed the code, so that the text "Save up to" is only shown if the amount from child products is different. I'm not sure if this is the best way, but it works (until yet only local, so I have got no link for a demo site). Maybe you can add this to the plugin even if you have said that you don't want to add new features.

    Code changes in classes/class-woocommerce-smart-sale-badge.php:

    1. Search for:
    $saving_amount = 0;

    Add after, in new line:
    $min_saving_amount = 999999999;

    2. Search for:
    $saving_amount = $new_saving_amount;

    Add after, in new line:

    if( $new_saving_amount < $min_saving_amount ) {
    $min_saving_amount = $new_saving_amount;

    3. Search for:
    $button_text = __( 'Save up to', 'wc_smart_sale_badge' );

    Change to:

    if( $saving_amount != $min_saving_amount ) {
    $button_text = __( 'Save up to', 'wc_smart_sale_badge' );
    } else {
    $button_text = __( 'Save', 'wc_smart_sale_badge' );


  2. Hugh Lashbrooke
    Plugin Author

    Posted 2 years ago #

    That could work - I don't like setting the default min saving amount to 999999999 though so I might find a more elegant solution, but I'll look into this as a feature for the next release.


  3. Apfelbiss
    Posted 2 years ago #

    Thanks, that that would be great :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce Smart Sale Badge
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.