php-shopify icon indicating copy to clipboard operation
php-shopify copied to clipboard

Updating Stock

Open duqkefly opened this issue 4 years ago • 3 comments

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.?

duqkefly avatar Aug 04 '20 17:08 duqkefly

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

e316 avatar Aug 06 '20 05:08 e316

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)]);

itsrexb avatar Feb 27 '21 10:02 itsrexb

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

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

tos1973 avatar May 19 '21 20:05 tos1973