Product GET not showing inventory quantity


Running the above fetch to try and work with the variant quantity on the checkout page. My goal is to hide the “Pick Up” option if the cart contains an item that is marked with “continue selling when out of stock” and the quantity is 0. We only want to continue selling these items with shipping and not pick up. Unfortunately this call is working and showing the variants in my cart but I can’t get to the inventory_quantity from here it seems. Any help is appreciated. Images are show the data I want to access is available on the product page but not within the checkout.

This is a feature to prevent inventory data leaking to the public. Usually inventory quantity is only part of the product object when accessed via liquid. You can either work around this, or have the account owner request Shopify flip a flag on the backend that allows this to be accessed via ajax, with the caveat that all product inventory will be available to competitors/public.

As for work arounds, one thing I’ve done is use liquid to create a javascript object/boolean that contains this information without actually giving out the inventory number. In your case you could do a liquid condition that checks both availability and stock level, then render something different, or create a javascript object/boolean to be read by your variant change/update code.

Thank you for your answer @iDoThemes ! How would one go about setting a JS variable with liquid. I can’t figure out how to get the desired result I am looking for. I have tried the following just to get some output to get started.

I’ve tried this in a script:


I’ve tried this within the actual page itself:

{% for item in cart.items %}
  {{item}}
{% endfor %}

I can’t get at anything within the cart with liquid on the checkout page it seems. Any advice?

Kind regards.

You use the liquid loop to add properties to your object. For example: