Development discussions around Shopify APIs
I'm trying to update the value of each option's position in order to reorder my options and have not been successful in doing so. When making the PUT calls, I'll get a 200 response but when parsing through the value of the options key in the product object that is returned, the position values have not changed.
I'm making PUT requests with the following payload:
{"product": {"id": 343297745, "options": [{"position": 1, "product_id": 343297745, "id": 404882001, "name": "Style"}, {"position": 3, "product_id": 343297745, "id": 404882005, "name": "Color"}, {"position": 2, "product_id": 343297745, "id": 404882009, "name": "Size"}]}}
I'll get a 200 response but the Options object looks like this:
[{"position": 1, "product_id": 343297745, "id": 404882001, "name": "Style"}, {"position": 2, "product_id": 343297745, "id": 404882005, "name": "Color"}, {"position": 3, "product_id": 343297745, "id": 404882009, "name": "Size"}]
Can someone help?
Because you are including the position in the request they are getting sorted then updated in the order based on that position value and not on their position in the array. If you want to be able to use the index of the entries, simply drop the position value and they will be stored in that order.
Chris | 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 the Shopify Help Center or the Shopify Blog
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023