phpclassic / php-shopify

PHP SDK for Shopify API
Apache License 2.0
570 stars 210 forks source link

Updating Stock #175

Open duqkefly opened 4 years ago

duqkefly commented 4 years ago

Hi Master.

How i cant adjust a product stock.??

I tried using the following but its not working for me.

$data = [ "price" => round(###,##), "inventory_level" => [ "inventory_item_id" => ????, (I dont know if this item is optional:?) "inventory_quantity" => ### ] ]; $res = $spf->Product($id_producto)->Variant($id_variant)->put($data);

How is the right way to do this.?

e316 commented 4 years ago

This is due to the new inventory_item api changes, You no longer update a product directly but instead create inventory_items for the product.

https://shopify.dev/docs/admin-api/rest/reference/inventory/inventoryitem?api[version]=2020-07

itsrexb commented 3 years ago

How can we get access to this scope?

PHPShopify \ Exception \ ApiException (403)
[API] This action requires merchant approval for read_inventory scope.

For example:
$inventoryItems = $shopify->InventoryItem()->get(['ids' => implode(',', $inventoryItemsIds)]);
tos1973 commented 3 years ago

Try this: $qty = array ( "location_id" => '1234567', "inventory_item_id" => '22334455', "available" => 25 );

$result = $shopify->InventoryLevel->set($qty);