@anker-in/shopify-react 0.1.1-beta.22 → 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.
@@ -4,8 +4,7 @@ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, Attrib
4
4
  import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter } from '../types-Dt0DUG00.mjs';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { SWRConfiguration } from 'swr';
7
- import { e as PlusMemberSettingsMetafields } from '../types-C1So3siD.mjs';
8
- import 'swr/mutation';
7
+ import { e as PlusMemberSettingsMetafields } from '../types-BSsb8OPm.mjs';
9
8
 
10
9
  interface ShopifyContextValue {
11
10
  client: ShopifyClient;
@@ -4,8 +4,7 @@ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, Attrib
4
4
  import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter } from '../types-Dt0DUG00.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { SWRConfiguration } from 'swr';
7
- import { e as PlusMemberSettingsMetafields } from '../types-C1So3siD.js';
8
- import 'swr/mutation';
7
+ import { e as PlusMemberSettingsMetafields } from '../types-BSsb8OPm.js';
9
8
 
10
9
  interface ShopifyContextValue {
11
10
  client: ShopifyClient;
@@ -931,7 +931,7 @@ var useUpdateLineCodeAmountAttributes = ({
931
931
  );
932
932
  const functionEnvValue = getDiscountEnvAttributeValue(line.customAttributes);
933
933
  const hasSameFunctionEnvAttribute = Number(functionEnvValue.discounted_amount) === Number(line.totalAmount);
934
- if (!hasSameFunctionEnvAttribute && hasFunctionEnvAttribute) {
934
+ if (!hasSameFunctionEnvAttribute && hasFunctionEnvAttribute && !functionEnvValue.is_gift) {
935
935
  attrNeedUpdate.push({
936
936
  key: CUSTOMER_ATTRIBUTE_KEY,
937
937
  value: JSON.stringify({
@@ -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
  );