【问题标题】:Shopify Inventory_quantity field not updating using shopify APIShopify Inventory_quantity 字段未使用 shopify API 更新
【发布时间】:2013-11-09 19:43:07
【问题描述】:

我正在尝试使用 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,消息 - 已找到,但库存数量未重置。提前致谢。

【问题讨论】:

  • 我也尝试将 POST 更改为 PUT,但没有任何区别。
  • 您有一个) 额外的括号。从末尾删除一个。

标签: php json api shopify


【解决方案1】:

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

【讨论】:

  • 这应该是一条评论
【解决方案2】:

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

“inventory_management”:“shopify”

如响应中所示:“更新现有变体的库存计数”

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

【讨论】:

    【解决方案3】:

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

    试试:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-17
      • 2020-01-13
      • 1970-01-01
      • 2020-06-30
      • 1970-01-01
      相关资源
      最近更新 更多