Variant inventory in REST API not matching site

Solved
Highlighted
New Member
4 0 0

Hi, I am having a problem to get the Stock of a product. I do:

https://krost-hav.myshopify.com/admin/api/2020-07/products/1839410970737.json

And I get the response:

"product": {
"id": 1839410970737,
"title": "XX",
"body_html": "Hide info",
"product_type": "popular",
"created_at": "2018-11-05T10:27:02-05:00",
"handle": "future-leaders-tee",
"updated_at": "2020-08-11T21:48:25-04:00",
"published_at": "2018-11-15T11:07:39-05:00",
"template_suffix": "",
"published_scope": "global",
"tags": "first semester",
"admin_graphql_api_id": "gid://shopify/Product/1839410970737",
"variants": [
{
"id": 18548988412017,
"product_id": 1839410970737,
"title": "S",
"price": "xxx",
"sku": "FUT-S",
"position": 1,
"inventory_policy": "deny",
"compare_at_price": "60.00",
"fulfillment_service": "manual",
"inventory_management": "shopify",
"option1": "S",
"option2": null,
"option3": null,
"created_at": "2018-11-05T10:27:03-05:00",
"updated_at": "2020-06-08T11:57:35-04:00",
"taxable": true,
"barcode": "",
"grams":x,
"image_id": 5906007261297,
"weight": 10.0,
"weight_unit": "oz",
"inventory_item_id": 18823473987697,
"inventory_quantity": 2,
"old_inventory_quantity": 2,
"requires_shipping": true,
"admin_graphql_api_id": "gid://shopify/ProductVariant/18548988412017"
}]

}

 

However, when i go to the store and see the product (https://krostnewyork.com/products/future-leaders-tee?variant=18548988412017) it is out of stock. Can you help me with this?

Thanks!

0 Likes
Highlighted
Shopify Expert
4270 32 435

This is an accepted solution.

If those 2 items are in some cart(s) then you would be faced with out of stock messaging. Shopify takes stock out of inventory to place into carts so just because the JSON shows a 2 does not mean there is actually 2 on the shelf. There could be 2 in a cart so zero on a shelf. Once the cart is abandoned or checkout completes, then that 2 is finalized once again, either as a zero because they were bought, or a 2 again, as the cart was destroyed and the contents were returned to the inventory for others to purchase.

Right?

Usually if you want the correct current inventory for a SKU you should use an API call to the InventoryLevel endpoint, providing the variant's inventory_item_id and the location ID it was assigned to. With multilocation inventory, your approach of asking for inventory simply by looking at the quantity from a product call is not terribly accurate anyway.

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Highlighted
New Member
4 0 0

Sorry to bother again, but I have tried this and it does not seem to work like that. 

I added the 2 products to my cart in one session and then asked a friend to enter the same product and they still see the product available, so this shows that it does not work this way (at least from what I could test). Any other idea why this could happen? Or am i missing something here?

 

Thanks!

0 Likes
Highlighted
Shopify Expert
4270 32 435

You lost me. You said the product was showing out of stock. Now you say it is showing it in stock. What is the actual problem?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
New Member
4 0 0

I am sorry if I was not clear. The problem is the same. In the response of the API, I get that there are 2 products in the inventory. When I go to the site, I see the product is Out of Stock. I understand what you explained me about the shelf, but I tried this approach to see if that was actually the problem and I could not verify that. What I tried to explain in the last message was HOW I tried to check your answer and failed. Here is what I did to test what you told me:
I added those 2 products to a cart, and asked a friend to see if the product was still available for him and altough I had those 2 products in my cart, he could add those to his cart.. so that kind of confused me from your answer.
I hope I was clear, and sorry for the misunderstanding.

0 Likes
Highlighted
Shopify Expert
4270 32 435

How do you know it is out of stock? Is that just Liquid telling you that? You said you friend was able to add those items, so your friend is not seeing it out of stock, only you?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
New Member
4 0 0

Exactly. I add those 2 items to my cart, then, I refresh and see that the item appears as "Sold Out". After that, I asked my friend to check if it appears like that for him too, but it does not. It lets him add to cart (max 2 items, of course). 

Screen Shot 2020-10-21 at 09.16.10.pngScreen Shot 2020-10-21 at 09.16.20.png

0 Likes