我目前正在为客户构建一个网站,他们要求最少购买6件商品。因此,如果顾客只有5件商品并点击结账,则需要警告他们必须至少购买6件商品。我目前使用JavaScript的
以下是我目前所拥有的代码:
alert
来警告他们,但这不允许自定义。我想添加一个Bootstrap模态框,但无法弄清楚如何操作。以下是我目前所拥有的代码:
<script>
paypal.minicart.render();
paypal.minicart.cart.on('checkout', function (evt) {
var items = this.items(),
len = items.length,
total = 0,
i;
// Count the number of each item in the cart
for (i = 0; i < len; i++) {
total += items[i].get('quantity');
}
if (total < 6) {
alert('The minimum order quantity is:\n\n3 Cases of Beer\n6 Bottles of Wine\n6 Bottles of Spirits.\n\nPlease add more to your shopping cart before checking out');
evt.preventDefault();
}
});
</script>