javascript - Bigcartel Api get remaining items in Stock -
working on custom big cartel theme , done, part doesn't work when user updates number of products in cart, can set number value greater remaining stock. using big cartel api has variable called product var
product.options- returns of options of product whether sold out or not.
i loop through options 1 product so
product.find(permalink, function(product) { console.log("i found " + product.name + "!"); var len=(product.options.length); console.log(len); for(var = 0; i<len;i++){ console.log((product.options[i])); } });
the "option" object, according api has field
option.quantity returns quantity left in stock option.
well when examine object loop prints
object {id: 153343298, name: "small", price: 30, sold_out: false, has_custom_price: false}
and there no "quantity" field. here link api documentation, have idea? big cartel api docs
found answer, default when click checkout button on bigcartel 'cart.html' page, element looks this
<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>
it sumbits post request automatically checks if item quantity in cart greater remaining stock. element generates display error message looks has classes
<ul class="unstyled errors"> <!-- error message here--> </ul>
i couldn't see because custom css blocked element.
Comments
Post a Comment