slince / shopify-api-php

:rocket: Shopify API Client for PHP
MIT License
128 stars 47 forks source link

How get variant Cost #56

Closed zerdmer closed 4 years ago

zerdmer commented 4 years ago

How get variant Cost?

$variant->getCost(); doesn't work, some idea? thanks!

zerdmer commented 4 years ago

ok, i got it, but now:

$x=$client->getInventoryItemManager()->find($ProductVariantInventoryId); echo $x->getCost(); // get the cost echo $x->setCost(1.1); // doesn't work

zerdmer commented 4 years ago

even with $x->setCost("1.1") or $x->setCost("1,1") still doesn't work

zerdmer commented 4 years ago

THIS WORKS: $client->getInventoryItemManager()->update($ProductVariantInventoryId, [ "cost" => $NewCost ]); But the ->setCost should work, and it doesn't

maximzasorin commented 4 years ago

@zerdmer

All models in the library are simple value objects. The design of the library does not assume that calling the setter will perform a request to the API and change the value on the side of Shopify. The correct way to update the value is to use the update method.