LaVOZs

The World’s Largest Online Community for Developers

'; php - How to structure a Shopify API GET request to determine inventory level given location_id and inventory_item_id - LavOzs.Com

Context:

I am using the 'PHP Classic' PHP wrapper for the Shopify API Per the Shopify API documentation for the current API version (2020-01) illustrating the way inventory level relates to location and specific item: each product variant has a 1:1 relationship with an attribute inventory_item_id. An inventory level (count of inventory for that item) connects to one location and one inventory_item_id :

relationship of inventory attributes and locations Shopify API

Things I think I know:

Using the PHPClassic wrapper for Shopify API you can access API endpoints in the following way:

e.g.

$product = $shopify->Product(12345678)->get();

Will get you the information about product with id 12345678.

Similarly you can get child resources of endpoints like this:

$productID = 23564666666;
$productImages = $shopify->Product($productID)->Image->get();

What I am trying to do but don't know how:

I want to retrieve the inventory level for an item at a known location and with a known inventory item id, my current code below returns no result (empty). I can't tell if Inventory Level is a child of location or of inventory_item_id but I've tried a few ways of configuring the request including:

        $d = [              
            'inventory_item_id' => 1234567,
            'location_id' => 1234567
        ];

        $res = $shopify->InventoryLevel->get($d);

Print_r of $res is empty. How can I do this?

Related
How to determine whether an object has a given property in JavaScript
How do I get a YouTube video thumbnail from the YouTube API?
How to get Shopify to redirect to a subdomain of the application URL?
How to add items to the cart using the Shopify API
Bigcommerce API Update Inventory Levels (both normal inventory tracking and tracking by options)
Shopify - New order using the Shopify API - how to know tax and shipping?
Write requests to inventory_quantity and inventory_quantity_adjustment are no longer supported. Please use the Inventory Levels API
Shopify API, 406 response for PUT request from Google Apps Script UrlFetchApp
Shopify API Updating Inventory Levels Not Working
Shopify - inventory_quantity deprecation notification