hi all,
I’ve recently started using the Square API to create new items and item variations in our shop and I’ve noticed a difference in behaviour … when creating an item via the dashboard, you choose “stock received” as the action and when viewing the item afterwards, under variations, the stock value is “1”. But when using the catalog and inventory APIs to create an item, I use IN_STOCK as the state and when viewing the item in the dashboard, the stock value is “Edit variation details”. Why is this? Screenshots attached below.
Dan
This is not intentional - thank you for sharing this and the screen shot! Our engineering team will take a look.
1 Like
Quick follow up here after looking into it:
We do expect to show “Edit variation details” when you have stock tracking enabled at multiple locations.
If that was not the case for SKU VCS 7091, let me know - the server might be handling default values in an unexpected way when creating items.
Perhaps I’m missing a setting in the objects for the call. Here’s a PHP snippet:
$catalog_object = new CatalogObject(CatalogObjectType::ITEM, "#".$uniq_id);
$catalog_object->setPresentAtAllLocations(false);
$catalog_object->setPresentAtLocationIds([$this->getLocationId()]);
should I also call setAbsentAtLocationIds()
? though looking at items we create via this method are only available at the one location. so it seems I’ve got that part of the call working.
To make sure I understand, I’ll summarize and you can correct anything I’ve misunderstood. The intent is to set the item variation for VCS 7901 as available at one location. Based on the screen shot of the display in the Dashboard, it would appear to be available at multiple locations.
The snippet you shared sets location at the item level; item variations can also be configured to track stock on the CatalogItemVariation object. I think stock tracking being on at multiple locations is what is causes “Edit Variation Details” to display in the stock row on the client.
ah I see… so I’m just setting the tracking of inventory to true on the item variation object. but I really need to use the ItemVariationLocationOverrides
object, yes
ok - got it all figured out now. thanks for the help!!