New cost property on InventoryItem

KieranMasterton
Shopify Staff (Retired)
22 0 12

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.

Replies 43 (43)
Gravy_Sales
Shopify Partner
55 1 6
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
High ticket item store owner and Google Shopping Ads specialist.
Shopify App: Gravy App that lets you build social proof with photo reviews, sales/cart pop-ups and referrals.
ClementG
Shopify Partner
659 0 136

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...

Gravy_Sales
Shopify Partner
55 1 6

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;

High ticket item store owner and Google Shopping Ads specialist.
Shopify App: Gravy App that lets you build social proof with photo reviews, sales/cart pop-ups and referrals.
KieranMasterton
Shopify Staff (Retired)
22 0 12

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.

ClementG
Shopify Partner
659 0 136

Thanks Kieran, I can see the cost in the webhook now.

Zapfor_Apps
Shopify Partner
80 1 11

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

SimplyCost - Add costs and track profit (https://apps.shopify.com/simplycost)
KieranMasterton
Shopify Staff (Retired)
22 0 12

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.

Ameed_Akhdar
New Member
2 0 0

Hey guys!

 

Is there any way to record cost of previous goods sold prior this feature was introduced? 

 

Thanks!

Zapfor_Apps
Shopify Partner
80 1 11

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

SimplyCost - Add costs and track profit (https://apps.shopify.com/simplycost)
ClementG
Shopify Partner
659 0 136

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.