@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.
@@ -970,29 +970,22 @@ var useUpdateLineCodeAmountAttributes = ({
970
970
  }).filter(
971
971
  ({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
972
972
  ).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
973
+ let lineId = line.id;
974
+ let attributes = line.customAttributes || [];
975
+ if (attrNeedDelete.length) {
976
+ attributes = attributes.filter(
977
+ (attr) => !attrNeedDelete.includes(attr.key)
978
+ );
979
+ }
973
980
  if (attrNeedUpdate.length) {
974
- return {
975
- id: line.id,
976
- attributes: [
977
- ...line.customAttributes?.filter(
978
- (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
979
- ) || [],
980
- ...attrNeedUpdate
981
- ]
982
- };
983
- } else if (attrNeedDelete.length) {
984
- return {
985
- id: line.id,
986
- attributes: line.customAttributes?.filter(
987
- (attr) => !attrNeedDelete.includes(attr.key)
988
- ) || []
989
- };
990
- } else {
991
- return {
992
- id: line.id,
993
- attributes: line.customAttributes || []
994
- };
981
+ attributes = attributes.filter(
982
+ (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
983
+ ).concat(attrNeedUpdate);
995
984
  }
985
+ return {
986
+ id: lineId,
987
+ attributes
988
+ };
996
989
  }),
997
990
  [cart?.lineItems, mainProductDiscountCodes]
998
991
  );