简体   繁体   English

在shopify产品中添加多个变体选项

[英]Add multiple varient options in shopify product

I am trying to add multiple options like size/color/type in the product but no matter whatever i do i am only able to add 1 option, if i add more than one, i get just a flag with status "False" and no other error. 我正在尝试在产品中添加多个选项,例如尺寸/颜色/类型,但是无论我做什么,我只能添加1个选项,如果我添加多个选项,我只会得到状态为“ False”的标志,而没有其他错误。 I am using shopify api. 我正在使用shopify api。

Try 1: 尝试1:

new_product.options = [{"name" : "Color", "values": ['p', 'k', 'l'], "position": 1}]
new_product.options = [{"name" : "Size", "values": ['p', 'k', 'l'], "position": 2}]
new_product.options = [{"name" : "Type", "values": ['p', 'k', 'l'], "position": 3}]

With this method only the last one will be added, which means that the next statement replaces previous one even when i gave the position. 使用这种方法,只会添加最后一个,这意味着即使我给出了职位,下一条语句也会替换上一条。 Also when Type is added in the product, the values also are not added in product and "Default Title" is shown. 同样,当在产品中添加类型时,产品中也不会添加值,并显示“默认标题”。

Try 1: 尝试1:

 new_product.options = [{"name" : "Color"}, {"name" : "Size"}, {"name" : "Type"}]

Again only 1 was added in product. 同样,产品中仅添加了1个。

Try 2: 尝试2:

opt1 = shopify.Option()
opt1.name = "Color"
opt2 = shopify.Option()
opt2.name = "Size"
opt3 = shopify.Option()
opt3.name = "Type"

#This works, no matter which one i add.
new_product.options = [opt1]

#This does not.
new_product.options = [opt1, opt2, opt3]
new_product.options = [{"name": "Color"}, {"name": "Size"}, {"name": "Type"}]
new_product.variants = shopify.Variant(dict(price=float(price.replace("$", "")), inventory_management="shopify", inventory_quantity=100, option1="Red", option2="36", option3="Type"))

Problem was solved, the issue was not that Other options were not added. 问题已解决,问题不在于未添加其他选项。 The actual issue was that Shopify did not allow more than one empty options. 实际的问题是Shopify不允许使用多个空选项。 So it was required that i add the values as well. 因此,要求我也添加值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM