Tracking oversold items in Shopify via (official Shipify API)

Good afternoon! I am using this Shopify API for a project which utilizes web hooks for customer orders. The Shopify admin settings for product variants allow customers to purchase items that are out of stock. I have spoken with the Shopify customer support 4 times before this to gather information about this, and they informed me that Shopify's customer support is not equipped to help me with the Shopify API.

My question is this, I know that the orders web hook response object gives information about a customers order in the object, such as "line_items", "customer", and other information about the order. If a customer buys more of an item than I have in stock, is there anything in the Shopify API such as a web hook that will show me on the customers order how many items that they purchased are in stock, and how many were oversold?

In the order web hook response object, in the nested object "line_items" there are two properties, one called "quantity", which is the amount purchased by the customer, and another property called "fulfilled_items" which I now know is the amount that you can manually fulfill in the Shopify admin page. Is there anything in the order web hook object or anywhere else in the API that will allow me to do this?

This is the official Shopify API: https://github.com/MONEI/Shopify-api-node

Thanks in advance, Michael

Upvotes: 0

Views: 294

Answers (1)

David Lazar
David Lazar

Reputation: 11427

If you examine the order line items, each line item sold should have an inventory_item_id. You can use this to call the Inventory Level API endpoint. That will tell you how many of those items remain in inventory.

So you can have the quantity ordered by the customer in the line item of the order, and you can have the quantity in your inventory. So you can now do the simple math to determine if you're oversold or not.

Note that to cheat at this, if you examine the line items inventory_quantity (or ask the Variant API endpoint for the variant's details) you'll get that amount, and it represents the total amount of that item available across all your locations. So you might see a 10 as much as a -6...

Have fun!

Upvotes: 0

Related Questions