2013-02-27 67 views
0

是否有可能檢查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 
} 

有沒有辦法?

回答

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; 
    } 
}); 
相關問題