@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.
@@ -961,29 +961,22 @@ var useUpdateLineCodeAmountAttributes = ({
961
961
  }).filter(
962
962
  ({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
963
963
  ).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
964
+ let lineId = line.id;
965
+ let attributes = line.customAttributes || [];
966
+ if (attrNeedDelete.length) {
967
+ attributes = attributes.filter(
968
+ (attr) => !attrNeedDelete.includes(attr.key)
969
+ );
970
+ }
964
971
  if (attrNeedUpdate.length) {
965
- return {
966
- id: line.id,
967
- attributes: [
968
- ...line.customAttributes?.filter(
969
- (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
970
- ) || [],
971
- ...attrNeedUpdate
972
- ]
973
- };
974
- } else if (attrNeedDelete.length) {
975
- return {
976
- id: line.id,
977
- attributes: line.customAttributes?.filter(
978
- (attr) => !attrNeedDelete.includes(attr.key)
979
- ) || []
980
- };
981
- } else {
982
- return {
983
- id: line.id,
984
- attributes: line.customAttributes || []
985
- };
972
+ attributes = attributes.filter(
973
+ (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
974
+ ).concat(attrNeedUpdate);
986
975
  }
976
+ return {
977
+ id: lineId,
978
+ attributes
979
+ };
987
980
  }),
988
981
  [cart?.lineItems, mainProductDiscountCodes]
989
982
  );