【问题标题】:Simplecart.js Check if Simplecart_Items has itemsSimplecart.js 检查 Simplecart_Items 是否有项目
【发布时间】:2013-02-27 16:00:03
【问题描述】:
是否可以像这样检查 div class simplecart_items 中是否有项目?
if simplecart_items == 0 {
NO ITEMS IN THE CARD // Shows no add to card, no total coast and no products quantity
}
else {
The "normal" output // Shows add to card, total coasts and products
}
有办法吗?
【问题讨论】:
标签:
javascript
shop
simplecart
【解决方案1】:
你可以在simplecartjs脚本的V3中尝试这种方式,
if(simpleCart.items().length == 0)
{
//No items in the cart
}
如果您想检查购物车中已经存在的特定商品,请使用 jQuery。
simpleCart.bind('beforeAdd', function (item) {
if (simpleCart.has(item))
{
alert("Already in the Cart");
return false;
}
});