"currentlyNotInStock" field on product variant is always returning "false" even when quantity is "0"

Highlighted
New Member
3 0 0

Hi,

 

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?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
586 71 128

Hey @tedisawesome,

 

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  unauthenticated_read_product_inventory permission.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Highlighted
New Member
3 0 0

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.

0 Likes