Shopify Admin API

Admin API 创建商品后库存无法设置怎么办

现象#

新商品创建成功,调用 inventorySetQuantities 报「inventory item not found at location」,前台一直显示缺货。

原因#

  • 商品未发布到该 location 对应的销售渠道
  • 未拿到 inventoryItem.id 与 location.id 的正确对应关系
  • 使用了 inventoryAdjustQuantities 但缺少 @idempotent 键
  • location 未启用履约或库存跟踪被关闭

处理步骤#

  1. 先查 productVariants 拿 inventoryItem.id
  2. 查 locations 确认目标 location 的 GID 且 isActive 为 true
  3. 调用 inventoryActivate 把 inventory item 在该 location 激活
  4. 再用 inventorySetQuantities 设置可用数量,name 用 available

验收标准#

指定 location 的可用库存与设置值一致,前台商品页显示可购买。

本文由 风格技术 技术团队整理,适用于 Shopify 标准版与 Plus 店铺。Shopify 平台能力迭代较快,具体操作路径与字段以官方文档和店铺后台实际版本为准。