Add Multiple Varient Options In Shopify Product

- 1 answer

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. I am using shopify api.

Try 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:

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

Again only 1 was added in product.

Try 2:

opt1 = shopify.Option() = "Color"
opt2 = shopify.Option() = "Size"
opt3 = shopify.Option() = "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. So it was required that i add the values as well.