FROM CACHE - en_header

Updating Order of Product Options

Arjun_Ohri
New Member
2 0 0

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?

 

Reply 1 (1)
Chris_Saunders
Shopify Staff
Shopify Staff
591 0 52

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