使用Custom Big Cartel主题并且我差不多完成了,唯一不起作用的部分是当用户更新购物车中的产品数量时,他们可以将数字设置为大于剩余库存的数量。使用Big cartel API,它有一个名为Product with var
的变量 product.options- Returns all of the options of a product whether they are
sold out or not.
然后我循环浏览一个产品的所有选项,如此
Product.find(permalink, function(product) {
console.log("I found " + product.name + "!");
var len=(product.options.length);
console.log(len);
for(var i = 0; i<len;i++){
console.log((product.options[i]));
}
});
“Option”对象,根据API有一个字段
option.quantity Returns the quantity left in stock for an option.
当我检查从循环中得到的对象时,它会打印
Object {id: 153343298, name: "Small", price: 30, sold_out: false, has_custom_price: false}
并且没有“数量”字段。这是API文档的链接,有没有人有任何想法? Big Cartel API Docs
答案 0 :(得分:1)
在您点击BigCartel&#39; Cart.html&#39;上的结帐按钮时,默认找到答案。页面,元素看起来像这样
<form method="post" action="/cart">
<ul class="plain_list">
... items in cart
</ul>
<p class="subtotal">
...
</p>
<button type="submit" name="checkout" title="Checkout">Checkout</button>
</form>
它会自动检查购物车中的商品数量是否大于剩余库存的过帐请求。它生成的用于显示错误消息的元素具有类
<ul class="unstyled errors">
<!-- Error Message here-->
</ul>
我无法看到这一点,因为我的自定义CSS会阻止该元素。