This topic and discussion board has been closed.
To stay updated on announcements related to the API please review this post about the new Developer changelog.
On Thursday October 25th, Shopify will start introducing Product Cost. This feature enables merchants to record the unit cost of their variants, track margin, and report on product performance within Shopify. This feature will roll out to all stores over the next few days.
Merchants will see a new cost per item field when editing variant pricing and will be able to bulk update this cost via the product CSV importer and the product bulk editor. There will also be changes to analytics, including the addition of new Profit Margin, Cost of Goods, and Gross Profit reports.
In order to enable our partners to leverage this feature in their apps we are exposing a new cost property on the InventoryItem. Please see the examples below for implementation details.
GraphQL
To pass Shopify the unit cost of a variant via the GraphQL Admin API you will use the productVariantUpdate mutation, see example below.
Mutation:
mutation productVariantUpdate($input: ProductVariantInput!) {
productVariantUpdate(input: $input) {
userErrors {
field
message
}
productVariant {
id
}
}
}
Input variables:
{
"input": {
"id": "gid://shopify/ProductVariant/35437260802",
"inventoryItem": {
"cost": "25.00"
}
}
}
For more information about variant mutations please see our documentation.
REST
To pass Shopify the unit cost of a variant using our REST Admin API you will use the InventoryItem endpoint, see example below.
PUT /admin/inventory_items/#{inventory_item_id}.json
{
"inventory_item": {
"id": 808950810,
"cost": "25.00"
}
}
For more InventoryItem endpoint information see our documentation.
As always, if you have any questions, or concerns, please don't hesitate to reply in the thread below.
Not yet seeing the "cost" on my store when I use the below format, with 12345 being inventory_item_id ... any ideas? myshop.com/admin/inventory_items/12345.json
Repricer Admin, we noticed the same thing when hitting the url in your browser, but if you use the API, the cost property will be returned. It seems pretty inconsistent...
It's missing in webhooks though. I'm waiting for a fix on that one...
Ah, thanks for confirming that... maybe/hopefully this is by design, to protect costs of shop owners. 🙂
So, just to confirm I have this right... this should work? On my dev store I'm still having no luck after iterating through $cost ...
$inv_request = $shop->api()->rest('GET', '/admin/inventory_items/12345.json');
$cost = $inv_request->body->inventory_item->cost;
Hi all,
For those implementing product cost in their apps we have just released a guide to supporting the new feature: https://help.shopify.com/en/api/guides/supporting-product-cost
Also, regarding the webhook issue Clement raised, we have just pushed an update which resolves this issue and also exposes the cost property to admin authenticated requests in the browser. Thanks for your patience while this was resolved.
Thanks Kieran, I can see the cost in the webhook now.
Hi Kieran,
I noticed when merchants update the cost per item field with CSV product import, the inventory_items/update webhook is not triggered. Is this by design? If it is, what do you recommend apps should do to detect changes in costs?
Thanks.
Sam
Hi Zapfor Solutions, thanks for the heads up on this, we're investigating the issue and will report back as soon as it's solved.
Hey guys!
Is there any way to record cost of previous goods sold prior this feature was introduced?
Thanks!
Hi Keiran,
Hi Zapfor Solutions, thanks for the heads up on this, we're investigating the issue and will report back as soon as it's solved.
I'd like to check if you have got any update regarding bulk import costs does not fire inventory_items/update webhooks?
Sam
We have deprecated our own cost field in favor of this new built-in field.
However, some merchants have reported to us that the field doesn't allow $0 cost.
It might seem strange at first but there are some valid scenarios that warrant a $0 cost, such as items on consignment or free items.
Is it possible to change the field to allow for this?
UPDATE:
It's worth noting that it is possible set a product price at $0 so it only makes sense to allow for the cost to be $0 as well.
@clement interesting question, can I ask for more context on the use case of a 0.00 cost? The cost can be set to null via GraphQL (coming to REST shortly) but I'm guessing perhaps your merchant has a specific use case for zero cost?
@sam this is still in the works, sorry for the delay and thanks for your patience.
As a merchant, I'd like to add my vote to Clement's request for a 0.00 cost.
We often have promotional inventory provided by suppliers free of charge, which we then re-sell. These sales should be recorded as 100% profit. It's my understanding that a product with a "null" cost field is ingored in the profit reporting.
Hi Kieran,
Would you like me to put you in touch with a merchant that requires $0.00 costs?
Like Adriano said, setting the cost to null doesn't work for reporting. A null cost is semantically different from a $0 cost. If the cost is null, we might want to exclude from profit reports or assume the margin is 0.
Seeing what type of information can be stored in this field via admin as is shopify tradition to be able to repurpose everything as a store needs with unexpected data. Just like most shopify handling of currency as pennies:
HI Kieran,
Please be informed that Google has already made the decision that the "Cost" field is important with how an item is presented for sale.
We need to map it properly to the Google Merchant Center "Cost_of_goods_sold" field so that we can optimize our marketing and the selling of our items.
Please confirm how we can do that.
Subscribed
Kieran, any update on allowing $0 cost?
I've just been pointed to another obvious use case by a merchant: digital products.
It's hard to argue with that one!
And yet another case with a merchant selling services.
Hello Shopify? Can you please allow $0 cost? It's impacting real merchants and real scenarios.
Hi Clement, sorry for the delay in replying over the holiday period. The development team working on product cost are in the process of implementing the zero cost option and it should be available very soon, I'll update the thread as soon as the feature is shipped. Thanks for your patience.
Thanks Kieran, great news!
Any update on capturing the historical cost on the order line items?
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023