Ad

Create Shopify Product With Options Permuated

- 1 answer

I was wondering how I can create a new item with mulitple option values preset. For example, A shirt has the options, Size: values: S, and Colour: values: R, G. When I do this manually on the Shopify admin, I get the options, S/R, S/G.

However, with the API, using the below as options doesn't generate the permutations of options.

{
  {
    ["name"]=>"Colour"
    ["values"]=>
    {
      [0]=>"Black"
    }
  }
  {
    ["name"]=> "Size"
    ["values"]=>
    {
      "XS"
      "S"
    }
  }
}

I know that you can use variants and assign option1 and option2, but that means I'll have to generate the permutations myself and send that post request. Is that the only way?

Ad

Answer

Yes. When you use the API to manually set things up, you are expected to write the code to ensure you provide the needed data in the needed keys and values. As you can see, manually setting up products does require a bit of organization and challenge.

Ad
source: stackoverflow.com
Ad