Simplecart.js检查Simplecart_Items是否有项目

Simplecart.js检查Simplecart_Items是否有项目

问题描述:

是否有可能检查div class simplecart_items是否包含项目,就像这样?Simplecart.js检查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 
} 

有没有办法?

您可以在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; 
    } 
});