FROM CACHE - en_header

Item Cost through Product API

Jonathan34
New Member
1 0 1

Hey everyone,

I'm looking for a way to use the product API to export to my system the Item Cost of every item I sell on the store. Is it already possible? Looking through the documentation I do not see any field called Item Cost.

 

Thank you

Replies 3 (3)
KarlOffenberger
Shopify Partner
1873 184 869

Hi, the item cost isn't kept at the product entity level, but on inventory item entity. Check inventory item docs.

Hope this helps!

Liked this post? You might also like our fantastic upsell apps Candy Rack, Last Upsell post-purchase and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
AshokRaja
New Member
1 0 1

Hi Shopify Team,

We were able to see from your documentation that in order to retrieve the Cost per Item(purchase price) of a product we have to first make a Product Details GET API call (admin/products/#{product_id}.json) and then obtaining the inventory_item_id from its response we have to make a GET API call /admin/inventory_items/#{inventory_item_id}.json and from this API call's response we are getting the cost value.

 

We wanted to know is this the only way of retrieving the Cost per item value associated with a Product? Is there a possibility of having just another node in Product Details GET API call (admin/products/#{product_id}.json) that contains the Cost per item value. As of now, it seems to be an overhead to call another API just to get the Cost per item.

 

Hoping to hear from you soon.

 

Thanks & Regards,

Ashok Raja | Zoho Inventory

KarlOffenberger
Shopify Partner
1873 184 869

Hi @AshokRaja, not from Shopify but I'll throw in what I know.

 

When using REST Admin API that would be correct and one way to avoid that is keeping a local index of variant ID <> inventory item ID.

 

If you can, use GraphQL Admin API which is far more flexible in this regard e.g.

query {
  productVariant(id: "gid:\/\/shopify\/ProductVariant\/10722878455923") {
    inventoryItem {
      unitCost {
        amount
        currencyCode
      }
    }
  }
}

And you could do the same for all product variants

query {
  product(id: "gid:\/\/shopify\/Product\/1011952287859") {
    variants(first: 100) {
      edges {
        node {
          inventoryItem {
            unitCost {
              amount
              currencyCode
            }
          }
        }
      }
    }
  }
}

And a few more ways but you get my drift - it's better for this use case.

 

Hope this helps!

Liked this post? You might also like our fantastic upsell apps Candy Rack, Last Upsell post-purchase and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie