gpt4 book ai didi

javascript - Bigcartel Api 获取库存中的剩余商品

转载 作者:行者123 更新时间:2023-12-03 03:46:24 25 4
gpt4 key购买 nike

正在开发自定义大卡特尔主题,我几乎完成了,唯一不起作用的部分是当用户更新购物车中的产品数量时,他们可以将数量设置为大于剩余库存的值。使用 Big cartel API,它有一个名为 Product 的变量,其中包含一个 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]));
}
});

根据API,“Option”对象有一个字段

          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

最佳答案

找到答案,默认情况下,当您单击 BigCartel 'Cart.html' 页面上的结账按钮时,元素如下所示

<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 阻止了该元素。

关于javascript - Bigcartel Api 获取库存中的剩余商品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45369547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com