Shopify Inventory_quantity字段未使用 shopify API 进行更新


Shopify Inventory_quantity field not updating using shopify API

我正在尝试使用Sandeep的Shopify API更新inventory_quantity。我的代码如下:

$variant = array
    (
            "variant"=>array (
                            "id"=>(int) {variant_id},
                            "inventory_quantity"=> (int) 0
            )
    )
);
$senditem = $shopify('POST', '/admin/variants/#{variant_id}.json', 
$variant, $response_headers);

状态代码为 302,消息 - 已找到,但库存数量未重置。 提前谢谢。

Raj,你在哪里写了上面的代码? 我的意思是在 Shopify 液体主题、页面或您正在使用外部页面 Shopify 网站 ?

您是否检查过该变体的"inventory_management"是"shopify":

"inventory_management": "购物化"

如回复中所示:"更新现有多属性的广告资源盘点"

http://docs.shopify.com/api/product_variant#update

您正在使用用于创建产品的"POST"方法。

尝试:

$senditem = $shopify('PUT', '/admin/variants/#{variant_id}.json', 
$variant, $response_headers);

"PUT"方法用于修改产品信息。

参考: https://help.shopify.com/en/api/reference/products/product-variant