Support » Plugin: WooCommerce Smart Sale Badge » "up to" only if different amounts

  • Hi.

    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' );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Hugh Lashbrooke


    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.


    Thanks, that that would be great 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘"up to" only if different amounts’ is closed to new replies.