在帖子上设置Shopify api变体选项标题
根据Shopify文档,您可以发布如下产品变体:在帖子上设置Shopify api变体选项标题,shopify,guzzle,Shopify,Guzzle,根据Shopify文档,您可以发布如下产品变体: "variant" => [ "title" => "Guzman", "price" => "44.90", "sku" => "160011", "position" => 1, "inventory_policy" => "continue", "compare_at_price" => null, "fulfillment_service
"variant" => [
"title" => "Guzman",
"price" => "44.90",
"sku" => "160011",
"position" => 1,
"inventory_policy" => "continue",
"compare_at_price" => null,
"fulfillment_service" => "manual",
"inventory_management" => "shopify",
"option1" => "Option1",
]
上面的例子是使用Guzzle。上面的代码发布到我引用的产品。问题是我找不到如何更改或设置选项标题。在示例中,默认名称为title:
在shopify管理员上,这将由“编辑选项”设置,但我在API文档中找不到关于如何设置的任何地方 据我所知,标题取决于您的选择。 如果选项1是红色,选项2是大的,标题将是
red/large
若要更改默认标题,请按如下在变量数组中传递标题字段中的选项值
PUT /admin/products/121212121212.json
{
"product": {
"id": 121212121212,
"variants": [
{
"title": "Guzman",
"price": 44.90,
"sku" :"160011",
"position": 1,
"inventory_policy": "continue",
"compare_at_price": null,
"fulfillment_service": "manual",
"inventory_management": "shopify",
"option1": "Guzman"
}
]
}
}
您可以在《邮递员》中试用,并让我知道这是否适合您。解决方案是变体标题实际上不是变体。它在产品api中 修改标题的正确方法如下:
$response = $shop->api()->rest('PUT', '/admin/products/{productId}.json' ,[
"product" => [
"option" => [
"name" => "Size"
]
]
]);
此处有更多文档:
让我扫兴的是,我在variantapi中,假设variant就是标题所在的位置。我的错。我以为您在使用产品API,我给了您一个使用产品API本身的API示例。向产品添加选项可能只会更改“默认标题”,但当您有多个选项时,您必须执行li'l extra:)