Development discussions around Shopify APIs
Hey everyone,
I'm looking for a way to use the product API to export to my system the Item Cost of every item I sell on the store. Is it already possible? Looking through the documentation I do not see any field called Item Cost.
Thank you
Hi, the item cost isn't kept at the product entity level, but on inventory item entity. Check inventory item docs.
Hope this helps!
Hi Shopify Team,
We were able to see from your documentation that in order to retrieve the Cost per Item(purchase price) of a product we have to first make a Product Details GET API call (admin/products/#{product_id}.json) and then obtaining the inventory_item_id from its response we have to make a GET API call /admin/inventory_items/#{inventory_item_id}.json and from this API call's response we are getting the cost value.
We wanted to know is this the only way of retrieving the Cost per item value associated with a Product? Is there a possibility of having just another node in Product Details GET API call (admin/products/#{product_id}.json) that contains the Cost per item value. As of now, it seems to be an overhead to call another API just to get the Cost per item.
Hoping to hear from you soon.
Thanks & Regards,
Ashok Raja | Zoho Inventory
Hi @AshokRaja, not from Shopify but I'll throw in what I know.
When using REST Admin API that would be correct and one way to avoid that is keeping a local index of variant ID <> inventory item ID.
If you can, use GraphQL Admin API which is far more flexible in this regard e.g.
query { productVariant(id: "gid:\/\/shopify\/ProductVariant\/10722878455923") { inventoryItem { unitCost { amount currencyCode } } } }
And you could do the same for all product variants
query { product(id: "gid:\/\/shopify\/Product\/1011952287859") { variants(first: 100) { edges { node { inventoryItem { unitCost { amount currencyCode } } } } } } }
And a few more ways but you get my drift - it's better for this use case.
Hope this helps!
User | RANK |
---|---|
8 | |
5 | |
3 | |
3 | |
3 |
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By