Admin API 创建商品后库存无法设置怎么办
现象#
新商品创建成功,调用 inventorySetQuantities 报「inventory item not found at location」,前台一直显示缺货。
原因#
- 商品未发布到该 location 对应的销售渠道
- 未拿到
inventoryItem.id与location.id的正确对应关系 - 使用了
inventoryAdjustQuantities但缺少@idempotent键 - location 未启用履约或库存跟踪被关闭
处理步骤#
- 先查
productVariants拿inventoryItem.id - 查
locations确认目标 location 的 GID 且isActive为 true - 调用
inventoryActivate把 inventory item 在该 location 激活 - 再用
inventorySetQuantities设置可用数量,name 用available
验收标准#
指定 location 的可用库存与设置值一致,前台商品页显示可购买。
本文由 风格技术 技术团队整理,适用于 Shopify 标准版与 Plus 店铺。Shopify 平台能力迭代较快,具体操作路径与字段以官方文档和店铺后台实际版本为准。