2017-07-28 58 views
0

处理自定义大卡特尔主题和我快完成了,唯一不起作用的部分是当用户更新购物车中的产品数量时,他们可以将数字设置为一个大于剩余股票的价值。使用大卡特尔API已经变量称为产品与VARBigcartel Api获取库存中的剩余物品

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])); 
    } 
}); 

“选项”对象,根据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文档的链接,有没有人有任何想法?当您单击BigCartel“Cart.html”页面上的结帐按钮 Big Cartel API Docs

回答

1

找到了答案,在默认情况下,该元素看起来像这样

<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> 

它sumbits POST请求,如果有任何自动检查您购物车中的商品数量大于剩余的商品数量。它生成的元素显示错误消息看起来有类

<ul class="unstyled errors"> 
     <!-- Error Message here-->     
     </ul> 

我看不到这是因为我的自定义CSS阻止元素。