Skip to content

Instantly share code, notes, and snippets.

@makfruit
Last active March 22, 2016 14:06
Show Gist options
  • Save makfruit/6698382 to your computer and use it in GitHub Desktop.
Save makfruit/6698382 to your computer and use it in GitHub Desktop.
An HTML/Javascript code snippet for Ecwid to show a simple promo message popup on the cart page for orders less than the defined subtotal
<!-- An HTML/Javascript code snippet for Ecwid to show a simple promo message popup on the cart page for orders less than the defined subtotal -->
<script>
if (typeof(Ecwid) == 'object') {
Ecwid.OnAPILoaded.add(function() {
var promoMessage = "Orders $99 and up ship free!";
var minSubtotal = 99;
var checkSubtotal = function(order) {
if (order) {
var subtotal = order.total - order.shipping;
if (subtotal < minSubtotal) {
alert(promoMessage);
}
}
}
Ecwid.OnPageLoaded.add(function(page) {
if ('CART' == page.type) {
Ecwid.Cart.calculateTotal(function(order) {
checkSubtotal(order);
});
}
});
});
}
</script>
@davidbiehl
Copy link

The tax also needs to be removed for an accurate subtotal. See this fork for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment