Focusing on managing products, variants, and collections through the API.
HI
I need to value the COGS (cost of goods sold) field from the management system using the API. But reading the documentation I don't see the existence of this property in GET and POST calls (/admin/api/2023-04/products.json).
I would like to know if it is feasible and how to implement it.
Thanks in advance.
Hi Dioufjunior,
As you've seen there isn't a direct endpoint for accessing COGS on a product directly. One option you could take would be the store the COGS value as a metafield on the product resource and then manage these values for products with the Admin API. Alternatively there are several third-party apps such as TrueProfit and Mipler available in the Shopify App Store that allow you to manage COGS. These apps provide their own APIs that you can use to integrate with your management system.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hello Liam and Dioufjunior,
The COST of a product is stored in Inventory_Items and you need the InventoryID to retrieve the unit cost.
You are correct that there is no direct request, you have to get the inventoryID first, then look it up in InventoryItems.
Jean