I used the cart attributes since they were entered and found most of the errors associated with them along the way (which Shopify fixed on the way), giving me enough confidence to inform you about this issue.
To edit them, simply place the cart with the same key that you used to create them and change the information. If you specify an empty value, you will delete the key. This is just the key: a store of values. As well as positions, which, incidentally, are edited in my book. I managed to edit them simply by changing the key value, and by specifying the value of the position index, perhaps you overlooked?
In any case, if you take the provided Shopify Javascript API code and explore this small library, you will see the functions used to create the attributes. With a few minor changes, you can introduce your own basket attribute CRUD function to suit your needs.
Here is an old example demonstrating updating the attributes of the basket, the data is a string, i.e.) "attributes [fizz] = 'buzz' (and note that you can save JSON this way):
updateCartAttributes: function(data, callback) { var params = { type: 'POST', url: '/cart/update.js', data: data, dataType: 'json', success: function(cart) { if ((typeof callback) === 'function') { callback(cart); } else { Shopify.api.onCartUpdate(cart); } }, error: function(XMLHttpRequest, textStatus) { Shopify.api.onError(XMLHttpRequest, textStatus); } }; $.ajax(params); }
source share