Kevin
Kevin

Reputation: 304

Create a new shopify product with multiple variants and options

I'm trying to create a product with multiple variants and options through Shopify API. How should I specify the options for each variant? Can I create multiple variants with one call? Thanks!

This is my JSON:

 {
 "handle":"carry-bag-grey",
  "body_html":"",
  "title":"Carry Bag(GREY)",   
  "product_type":"Women",
  "vendor":"MONOFOLD",
  "variants":[ 
  {
   "price":"23", 
   "fulfillment_service":"manual",
   "grams":"0",
   "inventory_management":"shopify",
   "inventory_policy":"deny",
   "sku":"MO1404180102",
   "taxable":"FALSE",
  "requires_shipping":"TRUE",
  "inventory_quantity":"2", 
  "Size":"6"
   },
  {
  "price":"23",
  "fulfillment_service":"manual",
  "grams":"0",
  "inventory_management":"shopify",
  "inventory_policy":"deny",
  "sku":"MO1404180103",
  "taxable":"FALSE",
  "requires_shipping":"TRUE",
  "inventory_quantity":"2",
  "Size":"6"
   }
 ]
}

I'm getting back a ActiveResource::ResourceInvalid (Failed.), does anyone know why?

Upvotes: 0

Views: 2170

Answers (1)

Steph Sharp
Steph Sharp

Reputation: 11672

Yes, you can create multiple variants with one call.

See the Shopify API docs here:

Create a new product with multiple product variants

POST /admin/products.json
{
  "product": {
    "title": "Burton Custom Freestlye 151",
    "body_html": "<strong>Good snowboard!</strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "variants": [
      {
        "option1": "First",
        "price": "10.00",
        "sku": 123
      },
      {
        "option1": "Second",
        "price": "20.00",
        "sku": "123"
      }
    ]
  }
}

Upvotes: 3

Related Questions