@anker-in/shopify-react 0.1.1-beta.23 → 0.1.1-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1639,29 +1639,22 @@ var useUpdateLineCodeAmountAttributes = ({
1639
1639
  }).filter(
1640
1640
  ({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
1641
1641
  ).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
1642
+ let lineId = line.id;
1643
+ let attributes = line.customAttributes || [];
1644
+ if (attrNeedDelete.length) {
1645
+ attributes = attributes.filter(
1646
+ (attr) => !attrNeedDelete.includes(attr.key)
1647
+ );
1648
+ }
1642
1649
  if (attrNeedUpdate.length) {
1643
- return {
1644
- id: line.id,
1645
- attributes: [
1646
- ...line.customAttributes?.filter(
1647
- (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1648
- ) || [],
1649
- ...attrNeedUpdate
1650
- ]
1651
- };
1652
- } else if (attrNeedDelete.length) {
1653
- return {
1654
- id: line.id,
1655
- attributes: line.customAttributes?.filter(
1656
- (attr) => !attrNeedDelete.includes(attr.key)
1657
- ) || []
1658
- };
1659
- } else {
1660
- return {
1661
- id: line.id,
1662
- attributes: line.customAttributes || []
1663
- };
1650
+ attributes = attributes.filter(
1651
+ (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1652
+ ).concat(attrNeedUpdate);
1664
1653
  }
1654
+ return {
1655
+ id: lineId,
1656
+ attributes
1657
+ };
1665
1658
  }),
1666
1659
  [cart?.lineItems, mainProductDiscountCodes]
1667
1660
  );