Call outside API to get inventory level and update Shopify inventory

Hi Spotify Community,

I am building a store that want to achieve the follow:

  • Get inventory level from outside API

  • Update inventory level in Shopify so that the order item quantity can be limited

Currently I am thinking if we can call the API when user click in the product page, so there will be a quantity indicator showing that how many qty is available in the warehouse. But I still want to limit the user to buy within the available qty range so to avoid excessive ordering. May I know if we are possible to achieve this?

Thanks a lot!

Hello @ringusgood ,

You can display the current inventory using Shopify liquid objects. For displaying it, you need to use this object on your product template:-

product.selected_or_first_available_variant.inventory_quantity

It is advised to implement it and make it compatible with your theme code with the help of a professional developer.

Hope it works. Let us know if any further help is needed.

All the best,

Team CedCommerce