0
votes

I'm using this example to get the inventory list:

try {
    $result = $api_instance->listInventory($location_id, $limit, $batch_token);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling V1ItemsApi->listInventory: ', $e->getMessage(), PHP_EOL;
}

I would like to create a items/products list out of it but I can't since it only returns "variation_id" and "quantity_on_hand". How can I get the item_id so I can retrieve the necessary details?

1

1 Answers

1
votes

If the item was created using the Square Dashboard, or via V2's UpsertCatalogObject then it will be a V2 catalog object. With the V2 object, you can use the RetrieveCatalogObject endpoint and pass the variation_id directly to get the variation's details (which includes name, price, and item_id).

If you used V1 CreateItem then it will be a V1 item, and the only way you can find the item_id using the variation_id would be to ListCatalog (or V1 ListItems) and loop through to find the item with the corresponding variation_id.

References: https://docs.connect.squareup.com/api/connect/v2#navsection-catalog

https://docs.connect.squareup.com/api/connect/v1#navsection-items