So we currently have a headless commerce site setup leveraging the JS Buy SDK and Storefront APIs so we can manage the cart experience on our own custom website.
We want to add in UI to display product variants that are out of stock and in the latest release of the Storefront API, we saw that there is a `currentlyNotInStock` field on the product variant.
However, when setting the quantity of the variant to 0 and making Shopify the inventory tracking manager, currentlyNotInStock is always returning as false instead of true as what I would expect since it's out of stock.
We have the products available in our custom Shopify private app which is not a sales channel. How is this currentlyNotInStock field getting set?
Thanks for bringing this up, I've tested on my end as well and it seems this field always returns false regardless of the actual state of inventory. I'll be raising this with our developers to clarify the expected behaviour and get a fix in place if necessary, I'll post back here with an update as soon as I have it.
In the meantime, you can consider using quantityAvailable which returns the actual number of units in stock. If you don't see this field, make sure your API client has the
Thanks @_JB !
Yeah I ended up using the `availableForSale` flag which does track the inventory quantity and does send back the correct value, BUT the products have to be enabled in the Shopify Online Store also. They don't work by default for the private apps we created for our headless commerce website.
Yeah let me know about the `currentlyNotInStock` as the verbiage of this field makes more sense than `availableForSale` as this has a bit different meaning.
Any updates on this? I'm getting the same issue with this. availableForSale seems to serve the purpose. can't use quantityAvailable field because some of our products' inventory are not tracked by shopify
Replying for future reference - this is intended behaviour that may have not been worded clearly enough at the time last year.
availableForSale will return false if no inventory is available for that variant.
currentlyNotInStock will return true only if the variant inventory quantity is <= 0 and overselling is allowed.
The ProductVariant docs were updated with descriptions that hopefully make this clearer: