New cost property on InventoryItem

KieranMasterton
Shopify Staff (Retired)
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)
Maris
Shopify Partner
313 5 71

Hi, Kieran!

This seemed like good news initially, but...

For us, the concern is (the same as with Multi-Location Inventory) the following - to read and write this value, that would require additional API call for each of variant inventory items.

Making the request complexity to be N+1 - as many requests as there are variants.

The suggestion (and expectation from us as API "customers") would be that this is the read+write attribute of the variant.

Earlier we suggested clients to store their "cost" in Variant Metafields which also is N+1 complexity, and my hope when reading this post, was to have good news for clients that now they can update their cost much faster with this attribute.

Can we update this attribute for all the variants of one product with one single request?

Thanks!

Matrixify (Excelify) | Bulk Import Export Update Migrate | https://matrixify.app
Danijel
Shopify Partner
21 0 18

Good change. This will be useful.

I strongly agree that the api needs support for batch operations. That, or relax the frustratingly low rate limit. 

KieranMasterton
Shopify Staff (Retired)
Shopify Staff (Retired)
22 0 12

Hi Maris & Danijel,

Glad that you both welcome this change. In terms of bulk updates to the cost property, I would suggest going the GraphQL route where you can add the cost on create and update for multiple variants.

Here's an example of creating a product with two variants and setting the variant's inventory item cost:

Mutation:

mutation productCreate($input: ProductInput!) {
  productCreate(input: $input) {
    userErrors {
      field
      message
    }
    product {
      id
    }
  }
}

Input variables:

{
  "input": {
    "title": "Product",
    "variants": [{
	  "title": "Variant 1",
      "options": "Red",
      "price": "55.00",
      "inventoryItem": {
      	"cost": "33.00"
      }
    },
    {
      "title": "Variant 2",
      "options": "Blue",
      "price": "55.00",
      "inventoryItem": {
      	"cost": "33.00"
      }
    }] 
  }
}

The same principle applies with the updateProduct mutation as well.

I hope that helps!

Maris
Shopify Partner
313 5 71

Yey, that's great, Kieran!

That's just what's needed!

Thanks!

Matrixify (Excelify) | Bulk Import Export Update Migrate | https://matrixify.app
Adriano_S
Tourist
3 0 3

As others have said, a very welcome change! Well done to the team!

From a business use perspective, one further request is to enable calculation of profit margins based on Product Prices that are exclusive of tax.

Example:

  • A store's product prices are stored inclusive of tax
  • "All taxes are included in my prices" is checked in Taxes settings
  • Provide a store setting to use the tax-exclusive product prices when calculating profit
Chris_C_
New Member
2 0 0

Hi there.  Will we be able to inupt/update this info via Transfer?  Also, will the COG update as they either increase/decrease depending on existing vs new stock?

Rick_Murt
Shopify Partner
5 0 4

Will the cost data be surfaced in the order admin? I applied a cost to a variant, then placed an order, and don't see any cost, margin or profit data anywhere. 

Jonathan-HA
Shopify Partner
275 15 87

Hi Kieran,

Would the `cost` field be availabe in the `Variant` API endpoint by any chance (even just as a read-only attribute)?

This would save us an additional API call to the InventoryItem just to pull the data (we have a reporting app).

Thanks!

Co-Founder / Developer at Highview Apps
Our Shopify Apps: EZ Exporter | EZ Inventory | EZ Importer | EZ Notify | EZ Fulfill
ClementG
Shopify Partner
660 0 144

Well done! I think a lot of merchants will be super happy about that.

I have to second others comment regarding bulk loading.

I have wondered since day one of the multi-location feature why the inventory item entity is not merged into the variant entity since there is a 1-1 relationship between them.

Unless there is a plan to enable inventory of non-variants in the future?

Steve54
Shopify Partner
7 0 1

HI Kieran,

Great new feature.  We will get around to adding it later on to our app, but for now if we don't pass the 'cost value' when updating products/variants that will be fine (ie. make no change to our existing processes)?

Thank you

GhostApps
Shopify Partner
145 1 15

Let me start by saying this is a useful feature that has been asked for by merchants for a while.

However, yet again your roll out has been terrible. After numerous delays to the app store and Locations API, you decide to roll out a new feature (that will kill a fair few apps) with 2 days notice!

Ultimately (after some redevelopment) this will help my app but the way you treat developers leaves a lot to be desired and I will have to look at reducing my dependence on your marketplace.

KieranMasterton
Shopify Staff (Retired)
Shopify Staff (Retired)
22 0 12

From a business use perspective, one further request is to enable calculation of profit margins based on Product Prices that are exclusive of tax.

Hi Adriano, great question, the new finance report gives an overview of margin without taxes. Shopify, Advanced, Plus plans also get the new Profit Margin reports which give this breakdown, per product and per variant.

 

Will we be able to inupt/update this info via Transfer?  Also, will the COG update as they either increase/decrease depending on existing vs new stock?

Hi Chris C, at present these feature are not available but this is a great suggestion and I'll feed this back to the product teams working on transfers and product cost.

 

Would the `cost` field be availabe in the `Variant` API endpoint by any chance (even just as a read-only attribute)?

Hi Jonathan & Clement, I'm afraid not. Our rationale is that anything which is an attribute of a physical good (their location, their weight, their cost, their quantity etc.) is at the inventory item level. Meanwhile, anything dealing with how an item is presented for sale to buyers (description, price, where it's published, images etc.) are at the product and variant level. I hope that makes sense.

if we don't pass the 'cost value' when updating products/variants that will be fine (ie. make no change to our existing processes)?

Hi Steve, it's great to hear you'll be adding product cost to your app and you're absolutely right, there's no requirement to pass the cost property.

 

However, yet again your roll out has been terrible. After numerous delays to the app store and Locations API, you decide to roll out a new feature (that will kill a fair few apps) with 2 days notice!

Hi GhostApps, thank you for your feedback on the timelines. It's not always possible for us to give advanced notice of feature releases but we are aware that the timeframe was particularly short in this case. I'll certainly raise your concerns internally and we'll envedour to give as much notice as possible in future. By enabling developers to set the product cost natively, we hope that partners will be able to leverage this data point, reducing their apps' dependency on storing cost data elsewhere and enabling them to concentrate on taking advantage of the huge opportunity in the product cost space.

Dan41
New Member
3 0 0

Perhaps I'm missing it, but to us the Cost of Goods Sold (and getting data out of shopify to complete taxes in general) challenge with Shopify isn't whether it can retain a product cost. 

The challenge for Cost of Goods Sold (and getting data out of shopify to complete taxes in general) is that this is no efficient way to get required data out of Shopify.  Also, in some cases there's no way to get the tax related data out of shopify tied back to the products/orders they came with. For example, Shopify has charged/refunded my customers and Charged/refunded me, but this needed tax related information/data is only avaiable under Shopify Bills with no way one can tie those amounts back to shopify orders, sales, etc.

We can and do record product cost today outside of shopify.  What we need from shopify for Cost of Goods Sold (and getting data out of shopify to complete taxes in general) is a feature where we can:

1) download all our shopify data,

2) download the data in a single area,

3) download data with its related keys (say between orders and bills (see above) in addition to sales, transactions, products, et al.) 

Will this new product cost (and/or report) also come with features to support (the above) so we can complete our Cost of Goods Sold and complete taxes in general? 

Tom48
New Member
1 0 0

Some of my clients have been asking for this for a while so it’s good to see it finally implemented. 

What would be really good is When raising an order via the pos or back office, the seller could view how much margin & profit is in the order. This would help them when they need to discount orders for customers. 

MercOlogy_Colla
Shopify Partner
1 0 0

I was pointed to this article as a solution to a Create Product Rest API error I am receiving:

Return Code: 400 Message: {"errors":{"smart_collection":"Required parameter missing or invalid"}}.  Oddly, when I run the same JSON in Postman, it created the Product.  

The Smart Collections use Vendor, Product Type and Tags to automatically associate the Product to the Collect.  I have confirmed that there are smart collections for the data in the JSON:

Can you help me understand why I was pointed to this article?  Doe the Create Product Rest API require Product Cost?

David

Dominique_Simon
Shopify Staff (Retired)
Shopify Staff (Retired)
11 0 9

Hi David,

 

I don't know why you were directed here, but if you are having issues creating products, you can create a new topic with the JSON youre sending to get help here:

 

https://ecommerce.shopify.com/c/shopify-apis-and-technology

 

Your issue is unrelated since you're using the product API. Is this a new error or did you just start using the API? (Please respond in the new topic)

 

Dominique

ClementG
Shopify Partner
660 0 144

Hi Kieran,

1) There seems to be a pretty bad bug: the cost property is not included in webhook requests for the inventory_items/update topic! I assume this is a bug?

It might affect inventory_items/create too but I didn't test it.

2) Is it possible to add a property on order line items with the cost at the time of the sale? Otherwise, we only have access to the current value, which may have changed since then.

 

KieranMasterton
Shopify Staff (Retired)
Shopify Staff (Retired)
22 0 12

Hi Clement,

1) Thanks for raising this, I've replicated the issue and will raise it with the engineering team immediately.

2) I know this isn't available at this point but I will ask the team if this is on the roadmap and update you shortly.

Maris
Shopify Partner
313 5 71

Hey, guys!

Today we ran into weeeird stuff with the Cost field with one of our Plus customers.

When setting the "cost" property though API to say "10.06", the Admin in the Plus store shows it as "10".

When reading from API the "cost" property, it is legitimately "10.06" there.

On the non-Plus Admin everything shows correctly of the same import.

Can Shopify Devs check this, please?

The client tried on many browsers, many computers - to eliminate the chance that this is a "OS/Browser" issue. It's the same. The only "common denominator" is that it is a Plus store.

Thanks!

Matrixify (Excelify) | Bulk Import Export Update Migrate | https://matrixify.app