FROM CACHE - en_header

Product With Multiple Options

Solved
hawkscode
Shopify Partner
177 14 12

I'm Trying To Create A Product With Multiple Product Option Here Is The JSON I'm Using.

API URL : https://xyz.myshopify.com/admin/api/2020-07/products.json

JSON :

{
	"product": {
		"title": "New Product Json",
		"body_html": "XYZ",
		"vendor": "MySHOP",
		"product_type": "",
		"published": true,
		"tags": "test, test new",
		"images": [{
			"src": "https://www.w3schools.com/w3css/img_lights.jpg"
		}],
		"variants": [{
			"title": "26\" x 36\" \/ Horizontal",
			"option1": "26\" x 36\"",
			"option2": "Horizontal",
			"sku": "16127874501899",
			"price": 29.95
		}, {

			"title": "51\" x 60\" \/ Horizontal",
			"option1": "51\" x 60\"",
			"option2": "Horizontal",
			"sku": "16127874501937",
			"price": 39.95
		}, {
			"title": "68\" x 80\" \/ Horizontal",
			"option1": "68\" x 80\"",
			"option2": "Horizontal",
			"sku": "16127874501039",
			"price": 49.95
		}, {
			"title": "88\" x 104\" \/ Horizontal",
			"option1": "88\" x 104\"",
			"option2": "Horizontal",
			"sku": "16127874501145",
			"price": 59.95
		}, {
			"title": "26\" x 36\" \/ Vertical",
			"option1": "26\" x 36\"",
			"option2": "Vertical",
			"sku": "161278745052",
			"price": 29.95
		}, {
			"title": "51\" x 60\" \/ Vertical",
			"option1": "51\" x 60\"",
			"option2": "Vertical",
			"sku": "16127874501494",
			"price": 39.95
		}, {
			"title": "68\" x 80\" \/ Vertical",
			"option1": "68\" x 80\"",
			"option2": "Vertical",
			"sku": "16127874501720",
			"price": 49.95
		}, {
			"title": "88\" x 104\" \/ Vertical",
			"option1": "88\" x 104\"",
			"option2": "Vertical",
			"sku": "16127874501733",
			"price": 59.95
		}]
	},
	"options": [{
		"name": "Size",
		"values": ["26\" x 36\"", "51\" x 60\"", "68\" x 80\"", "88\" x 104\""]
	}, {
		"name": "Alignment",
		"values": ["Horizontal", "Vertical"]
	}]
}

 

Error:

{
    "errors": {
        "base": [
            "The variant '26\" x 36\"' already exists."
        ]
    }
}

 

Please Anybody Can Help Me Out To Solve The Error. I'm Confused Where I'm Going Wrong

If helpful, please Like and Accept Solution

if you Want to Modify / Customize your theme , Feel free to contact me

Email : vikash.hawkscode@gmail.com


Skype : vikas.hawkscode


www.hawkscode.com

Accepted Solutions (2)

Accepted Solutions
_JCC_
Shopify Staff
Shopify Staff
196 27 50

This is an accepted solution.

@hawkscode ,

Happy to help you out with this.

From the code sample provided your options definition falls outside of the product object definition. Move the options definition into the product definition as illustrated below and everything should be fine.

09-02-03ilz-s26pl

Hope this helps, if you have any questions please don't hesitate to reach out.

Regards,

John 

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

hawkscode
Shopify Partner
177 14 12

This is an accepted solution.

Thanks 

If helpful, please Like and Accept Solution

if you Want to Modify / Customize your theme , Feel free to contact me

Email : vikash.hawkscode@gmail.com


Skype : vikas.hawkscode


www.hawkscode.com

View solution in original post

Replies 2 (2)
_JCC_
Shopify Staff
Shopify Staff
196 27 50

This is an accepted solution.

@hawkscode ,

Happy to help you out with this.

From the code sample provided your options definition falls outside of the product object definition. Move the options definition into the product definition as illustrated below and everything should be fine.

09-02-03ilz-s26pl

Hope this helps, if you have any questions please don't hesitate to reach out.

Regards,

John 

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

hawkscode
Shopify Partner
177 14 12

This is an accepted solution.

Thanks 

If helpful, please Like and Accept Solution

if you Want to Modify / Customize your theme , Feel free to contact me

Email : vikash.hawkscode@gmail.com


Skype : vikas.hawkscode


www.hawkscode.com