You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The useApplyCartLinesChange function allows updating a line item in the Shopify checkout. While it supports adding and updating custom attributes through the attributes array, it does not currently provide a way to remove an attribute that has already been added to the line item. This limitation prevents clearing or resetting custom attributes, which is necessary in certain scenarios.
Steps to Reproduce
Use the useApplyCartLinesChange hook to add custom attributes to a cart line item.
Attempt to remove a previously added custom attribute by passing an updated attributes array without the attribute you wish to remove.
Observe that the attribute remains in the line item instead of being removed.
Expected Behavior
When an updated attributes array is passed to the useApplyCartLinesChange function, any attributes missing from the array should be removed from the line item in the checkout.
Actual Behavior
Attributes that are not included in the updated attributes array remain in the line item, making it impossible to delete attributes.
Example Code
Here is an example of the issue:
constapplyCartLineChange=useApplyCartLinesChange();constupdateAttributes=async()=>{awaitapplyCartLineChange([{id: 'line-item-id',type: 'updateCartLine',attributes: [{key: 'custom_key',value: 'new_value'},// Adding or updating an attribute works],},]);// Attempting to remove the custom_key attributeawaitapplyCartLineChange([{id: 'line-item-id',type: 'updateCartLine',attributes: [],// Expected to remove all attributes},]);};// The `custom_key` attribute remains present after the second update.
The text was updated successfully, but these errors were encountered:
Description
The
useApplyCartLinesChange
function allows updating a line item in the Shopify checkout. While it supports adding and updating custom attributes through theattributes
array, it does not currently provide a way to remove an attribute that has already been added to the line item. This limitation prevents clearing or resetting custom attributes, which is necessary in certain scenarios.Steps to Reproduce
useApplyCartLinesChange
hook to add custom attributes to a cart line item.attributes
array without the attribute you wish to remove.Expected Behavior
When an updated
attributes
array is passed to theuseApplyCartLinesChange
function, any attributes missing from the array should be removed from the line item in the checkout.Actual Behavior
Attributes that are not included in the updated
attributes
array remain in the line item, making it impossible to delete attributes.Example Code
Here is an example of the issue:
The text was updated successfully, but these errors were encountered: