WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Apfelbiss
    Member
    Posted 1 year ago #

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

    http://wordpress.org/extend/plugins/woocommerce-smart-sale-badge/

  2. Hugh Lashbrooke
    Member
    Plugin Author

    Posted 1 year 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.

    Thanks!

  3. Apfelbiss
    Member
    Posted 1 year ago #

    Thanks, that that would be great :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.