Cost on Orders API

Hi,

Now inventory items now have a cost
https://help.shopify.com/en/api/reference/inventory/inventoryitem

But where is the cost of a inventory item at the time of a sale recorded? I can not see it on the order API.

Thanks,
Ryan

8 Likes

Hey Ryan,

Currently, this is not part of the Order API and the item cost is only stored at an inventory item level. I’ll pass this feedback along though, I definitely understand where you’re coming from and can see how this could be valuable.

1 Like

Interested by this feature too! Any news @Josh ?

I would also be interested in having “shipping costs” on the Order API.

1 Like

Hey guys,

No movement on this as of yet. Would you be able to provide some details on your planned use-cases for this? I can pass them along to our development teams. Often a solid use-case helps with getting things moving along.

1 Like

Hi @Josh ,

We are creating our own ERP using the Shopify API along with other APIs (Amazon, Facebook, Google Ads, etc…). The goal is to have access to real-time multi-channel revenues AND costs on a hourly basis.

To have a proper ERP, we need to be able to integrate not only revenue, but also costs. Revenue are easy to retrieve from Shopify API, but costs are unavailable even though we can add them on Shopify Admin platform.

The only solution for us today is to add custom rules to our ERP outside Shopify API. It would be much cleaner and faster if there were a “total_cost” field on the Order API and a “item_cost” field for each item in “line_items”.

Don’t hesitate to come back to me if you need more infos.

3 Likes

Hey again,

Thanks for getting back to me! That’s a great use-case in my opinion, and I’ve passed the feedback along to the relevant teams. I haven’t heard back as of yet, but will keep my fingers crossed.

2 Likes

According to this post, https://community.shopify.com/c/shopify-design/cost-per-item-historic-data/m-p/636121, shopify is storing the historic product cost. Any update on when this data will be available via the API?

3 Likes

Also wanted to add that the “Sales over time” report already has those fields: “cost recorded” and “cost”, but the api is missing them (https://shopify.dev/api/admin-graphql/2022-01/objects/Order#fields , https://shopify.dev/api/admin-graphql/2022-01/objects/LineItem#fields). Ive managed to find the cost field only in the inventoryItem block.

3 Likes

I am intereseted in this also

3 Likes

Hi, I would also highly value this being added to the shopify API. Is there any update?

4 Likes

This seems like this has been in the works for a while. Any updates on this? We need to be able to see historic cogs by order and line item in order to properly calculate margin over time.

3 Likes

I’m a merchant who needs this as well. We’re trying to build margin reports in Microsoft Power BI and we need to have consistency with what’s reported in shopify and what’s reported in Power BI. We need the recorded cost at the time of the order to do that.

4 Likes

@Josh Please include us as another partner who’s extremely interested in this data. Is there any news on if or when this will be available? We cannot reliably show merchants any COGS or profit information from before when they installed our app without this.

Thanks,

Greg

2 Likes

Hi @GregThoen :waving_hand:

You should be able to access this via the ](https://shopify.dev/api/admin-graphql/2023-01/objects/InventoryItem#field-inventoryitem-unitcost)[InventoryItem.](https://shopify.dev/api/admin-graphql/2023-01/objects/InventoryItem#field-inventoryitem-unitcost)[unitCost field. Working with orders, it would look something like the below:

{
    order(id:$orderID){
        lineItems(first:10){
            nodes {
                variant {
                    inventoryItem {
                        unitCost{
                            amount
                            currencyCode
                        }
                    }
                }
            }
        }
    }
}

Hope that helps!

Hi, @ShopifyDevSup

Thanks for the reply. I do know that we can get the current cost information of an InventoryItem there. However, there are 2 issues:

1 - Merchants can change the cost as the cost of acquiring the item changes over time.

2 - Merchants can delete products.

In both of these cases, the cost of an item at the time the Order was created is not available through the Variant/InventoryItem on the LineItem – in the first case, it’s the wrong cost; in the second case, the LineItem.variant is null.

However, in both cases, Shopify has recorded the correct cost of the product at the time of the order (because it shows it within its analytics reports). What we are all asking for is that Shopify expose that information in the API. An ideal place is probably directly on the LineItem.

Thanks,

Greg

5 Likes

Yes, @GregThoen is correct. Do you have any other insight into this @ShopifyDevSup ?

2 Likes

Thanks for clarifying @GregThoen !

At this time, we are limited to the InventoryItem.unitCost field, but I’ll be sure to share your use-cases with the product teams.

1 Like

** @ShopifyDevSup Please Help us !**Thank you @GregThoen et al for clearly pushing for this obvious and necessary improvement. See attached for the resulting unresolved use case where Cost Records=Yes AND Cost is recorded as zero.

    1. Salespersons can create a custom product on the fly but that custom product has no place to capture cost
  1. Salespersons can create a product and variants with Pricing but not know the costs until much later in time after the order has been Paid and Fulfilled.
  2. Merchants can change the cost as the cost of acquiring the item changes over time.
  3. Merchants can delete products. Especially harsh when the product and/or variant gets deleted and was on an order that has been paid and fulfilled.

Shopify has recorded the correct or incorrect cost of the product (see attached photo) at the time the order gets Paid and Fulfilled (because it shows it within its analytics reports correctly or incorrectly).

We are all asking for Shopify Devs to expose cost information via the LineItem ****object in the API for both query and create, update mutations.

My client and I would also highly value this. We are trying to get the most accurate picture of margins as costs change over time.

2 Likes

Any developments on this topic ?

Also two additional requests:

  1. any chance value of inventory_quantity (and perhaps also old_inventory_quantity) are stored as well on order level ? If so: could this also made available in line_items ?

  2. same for compare_at_price ? It would be very helpfull if this could be available too!

Thanks for reply!