Variant "cost" is reset when updating a product + variants through the REST api

Variant "cost" is reset when updating a product + variants through the REST api

nmrdxt1
Shopify Partner
3 0 1

When updating multiple variants of a product using the product's REST PUT endpoint, the cost per item field is reset for each variation.

 

For example, when putting this product:

 

$payload = [
'product' => [
'id' => 123456,
'variants' => [
[
'id' => 5678,
'sku' => 'abc',
],
[
'id' => 1234,
'sku' => 'def',
],
],
],
];

 

The SKUs would update okay, but the cost per item would reset per each variant. The expected behavior should be that the cost per item remain unaffected, and would only change if explicitly requested – am I missing something?

 

Thanks!

Replies 0 (0)