Shopify API:如何为指定VariantID设置不同币种价格?
正确通过API设置Shopify变体多币种价格的方法
REST API 实现方式
先确认请求体结构是否合规,presentment_prices需包含price和compare_at_price对象,且每个币种要对应已配置的市场。另外,若店铺开启了市场手动定价,需确保请求指定的币种对应已配置的市场。
正确的PUT请求示例(以2023-07版本为例):
- 端点:
https://{shop-name}.myshopify.com/admin/api/2023-07/variants/{variant-id}.json - 请求体:
{ "variant": { "id": {variant-id}, "price": "7.00", // 基准币种GBP的价格 "compare_at_price": null, "presentment_prices": [ { "price": { "amount": "7.00", "currency_code": "GBP" }, "compare_at_price": { "amount": null, "currency_code": "GBP" } }, { "price": { "amount": "100.00", "currency_code": "EUR" }, "compare_at_price": { "amount": null, "currency_code": "EUR" } } ] } }
注意:
- 基准币种的
price字段必须和presentment_prices中对应币种的amount一致,否则会被系统忽略 - 若之前在后台市场设置了自动转换,需先将对应市场切换为"手动设置价格"(后台路径:设置>市场>对应市场>定价)
GraphQL API 实现方式
使用productVariantUpdate mutation直接指定各币种的展示价格:
mutation { productVariantUpdate( input: { id: "gid://shopify/ProductVariant/{variant-id}", price: "7.00", presentmentPrices: [ { price: { amount: "7.00", currencyCode: GBP }, compareAtPrice: { amount: null, currencyCode: GBP } }, { price: { amount: "100.00", currencyCode: EUR }, compareAtPrice: { amount: null, currencyCode: EUR } } ] } ) { productVariant { id price presentmentPrices { price { amount currencyCode } } } userErrors { field message } } }
执行后可通过userErrors字段排查错误,比如币种未配置、权限不足等问题。
常见问题排查
- 检查API版本:
presentment_prices从2021-01版本开始支持,确保使用的版本不低于此 - 确认API权限:需拥有
write_products权限 - 后台市场设置:若对应市场设置为"自动根据基准币种转换",手动API设置的价格会被覆盖,需切换为手动定价模式
内容的提问来源于stack exchange,提问作者Grz3siu
相关产品推荐
相关产品推荐

