Adds new filter localized_url
that can be used to manipulate Ajax API’s URLs for Cart and Get Upsells/Recommendations
upside.ucd.filters.localized_url.push(e => {
// Prefix locale for cart api
if(e.type === 'cart' && Shopify.locale && Shopify.locale.toLowerCase() !== 'en')
{
e.url = '/' + Shopify.locale + e.url
}
return e;
})
Restrict max quantity for items if an attribute max or data-max is set. The following code sets maximum 10 quantity for related item.
<input type="text" max="10" ....other attributes here />
upside.ucd.filters.recharge_checkout_url = upside.ucd.filters.recharge_checkout_url || [];
upside.ucd.filters.recharge_checkout_url.push(function(url){
// Modify URL if needed and return it
return url;
});
Added new Handlebars truncate helper that can be used to truncate any text in the theme templates.
* @param {String} `str`
* @param {Number} `limit` The desired length of the returned string.
* @param {String} `suffix` Optionally supply a string to use as a suffix to denote when the string has been truncated.
{{truncate str 30 '...'}}
// Examples
{{truncate 'foo bar baz' 7}}
<!-- results in: 'foo bar' -->
{{truncate "foo bar baz" 10 "..."}}
<!-- results in: 'foo bar...' -->