Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Unable to update a product options

Unable to update a product options

lucacalabrese12
Visitor
2 0 1

I am able to add options and variants  creating a product:

POST

"options" => array(
           "name" => "Color",
           "values" => array(
                 "Pink",
                 "Red",
             ),
            "position" => 1,
),

"variants"=>array(
          array(
              "title"=> "Pink",
              "sku" => "A3POR44T",
              "option1"=> "Pinko",
              "inventory_quantity" => 11,
              "price"=>20.00,
              "taxable"=>false, 
              "inventory_management" => 'shopify'
        ),
        array(
             "title"=> "Red",
             "sku" => "POR44T",
             "option1"=> "Redo",
             "inventory_quantity" => 14,
             "price"=>23.00,
             "taxable"=>false, 
             "inventory_management" => 'shopify'
       )
)

But if I PUT another option and variant to said product, instead it substitutes all the variants and option with the new one.

How do I update (add) instead?

Replies 3 (3)

Jayvin
Shopify Partner
284 42 89

Hi,

Use the add variant endpoint instead

banned
lucacalabrese12
Visitor
2 0 1

Hello and thanks,

I tried it and I was able of course do add a variant to the product, I did in fact correctly create under the "Color" option automatically.

I did not indicate "Color" in any field of my POST. How did it know it was a value of the "Color" option?

What if I had 2 options? Or what If I had no options before?

Let's say I have a product with no variants (I know it creates one titled "Default title"), how do I add a new Color/yellow variant?

 

sunildath9
Shopify Partner
4 0 0

Are you able to solve this? We have the same issue. It will be a great help if you share the solution.