Development discussions around Shopify APIs
We have encountered two issues with changing product options after they have been created in certain circumstances. They could be related, however different errors are produced.
The first issue is removing the first option from an existing product that has two options. The remaining option is moved into the place of option one.
POST new product:
{
"product": {
"title": "Burton Custom Freestyle 151",
"body_html": "<strong>Good snowboard!</strong>",
"vendor": "Burton",
"product_type": "Snowboard",
"variants": [
{
"option1": "Small",
"option2": "Red",
"price": "10.00",
"sku": "123"
},
{
"option1": "Large",
"option2": "Blue",
"price": "20.00",
"sku": "456"
}
],
"options": [
{
"name": "Size",
"values": [
"Small",
"Large"
]
},
{
"name": "Colour",
"values": [
"Red",
"Blue"
]
}
]
}
}
PUT update to product, removing the size option:
{
"product": {
"title": "Burton Custom Freestyle 151",
"body_html": "<strong>Good snowboard!</strong>",
"vendor": "Burton",
"product_type": "Snowboard",
"variants": [
{
"option1": "Red",
"price": "10.00",
"sku": "123"
},
{
"option1": "Blue",
"price": "20.00",
"sku": "456"
}
],
"options": [
{
"name": "Colour",
"values": [
"Red",
"Blue"
]
}
]
}
}
Result:
{"errors": {"base": ["could not be saved successfully"]}}
The second issue is basically the opposite, when a product already has one option and a new option is added before the existing option. So option 1 moves to option 2, and the new option is inserted as option 1. This is necessary as our application always prioritises size over colour, but some products may initially have only a colour, and the size is then added later.
POST new product:
{"product":{"title":"Error adding option","variants":[{"price":20,"sku":"error1","option1":"Blue"},{"price":20,"sku":"error2","option1":"Red"}],"options":[{"name":"Colour","values":["Blue","Red"]}]}}
PUT product update, adding size option (replace XXXXXXXX with variant IDs):
{"product":{"vendor":null,"variants":[{"price":20,"sku":"error1","option1":"Small","option2":"Blue","id":XXXXXXXX},{"price":20,"sku":"error2","option1":"Large","option2":"Red","id":XXXXXXXX}],"options":[{"name":"Size","values":["Small","Large"]},{"name":"Colour","values":["Blue","Red"]}]}}
Result:
{"errors": {
"options": ["is invalid"],
"name": ["of Option is not unique"]
}}
However, the PUT request does work when the vendor field is removed (which we sometimes need to update simultaneously):
{"product":{"variants":[{"price":20,"sku":"error1","option1":"Small","option2":"Blue","id":XXXXXXXX},{"price":20,"sku":"error2","option1":"Large","option2":"Red","id":XXXXXXXX}],"options":[{"name":"Size","values":["Small","Large"]},{"name":"Colour","values":["Blue","Red"]}]}}
The PUT request also works when the options are in the original order, so the existing option remains as option1 and the new option is option2:
{"product":{"vendor":null,"variants":[{"price":20,"sku":"error1","option1":"Blue","option2":"Small","id":XXXXXXXX},{"price":20,"sku":"error2","option1":"Red","option2":"Large","id":XXXXXXXX}],"options":[{"name":"Colour","values":["Blue","Red"]},{"name":"Size","values":["Small","Large"]}]}}
If anyone is able to figure out what's going on here, that would be awesome.
Bump. Running into the same issues. Did you find a solution?
Same issue here. Any solution or advice? Thanks
I tried something and it worked. Uptil now we know that something is wrong with Shopify API when we try to PUT (update) an existing product and moving the existing option to second position.
The existing product had one option called "Color" and a PUT request to add an option "Size" on the first position and more "Color" to second position resulted in the following response (422):
{"errors":{"options":["is invalid"],"name":["of Option is not unique"]}}
To work around this issue, I broke my request into two requests:
That's how I succeeded in achieving my goal. I hope this helps someone looking for an answer. Thanks.
Thanks for the workaround, but we really do need Shopify to report errors more specifically so that we can work with this in an automated way.
Shopify??
I'm having a very similar issue, as exposed here. Can anyone tell me if the root cause has been found?
Two years later and I'm seeing the same issue as the OP. Guess I'll have to resort to the two-step change.
Just started happening for me too. Maybe something changed?
Same issues happen😂,why options can not edit easy。。。what i want is add size later or remove size option when necessary
lost me many many time to find a solution delete size option😁
fortunately I find it
1、What option you want remove must is last option,so if you want remove first you should reorder option
2、What option you want remove the value in variants must be same and can not be "Default Title"
User | RANK |
---|---|
10 | |
4 | |
3 | |
3 | |
3 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023