Created
February 28, 2020 14:11
-
-
Save Jedtek/6ee7b2e557d498be2bee542a1c186ff8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inside template {{#items}} loop I do this: | |
<div class="grid--full display-table"> | |
<div class="grid__item"> | |
{{{retNextDiscount itemQty properties }}} | |
</div> | |
</div> | |
helper in Custom Javascript is this: | |
Handlebars.registerHelper('retNextDiscount', function (qty, properties) { | |
if(typeof properties.subscription_id === 'string') { | |
return ''; | |
} | |
qty = Number(Handlebars.escapeExpression(qty)); | |
if(qty === 1) { | |
return '<small class="ucdcart-item__discount">5% off when buying 2</small><br>'; | |
} else if (qty === 2) { | |
return '<small class="ucdcart-item__discount">10% off when buying 3 or more</small><br>'; | |
} else if (qty >= 3) { | |
return '<small class="ucdcart-item__discount">You\'re getting our best discount! (10%)</small><br>'; | |
} | |
}); | |
I want to add SKU argument to function, so I can process discount text with SKU of variant |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment