@anker-in/shopify-react 0.1.1-beta.7 → 0.1.1-beta.8

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.
@@ -1351,15 +1351,19 @@ var useCartAttributes = ({
1351
1351
  ];
1352
1352
  }, [profile?.memberType, profile?.token, userType, hasPlusMember]);
1353
1353
  const functionAttributes = react.useMemo(() => {
1354
- return [
1355
- cart?.discountCodes && {
1354
+ const hasFunctionEnvAttribute = cart?.lineItems.some(
1355
+ (item) => item.customAttributes?.some((attr) => attr.key === CUSTOMER_ATTRIBUTE_KEY)
1356
+ );
1357
+ const discountCodes = cart?.discountCodes.map((item) => item.code).filter((code) => code) || [];
1358
+ return hasFunctionEnvAttribute ? [
1359
+ {
1356
1360
  key: "_discounts_function_env",
1357
1361
  value: JSON.stringify({
1358
- discount_code: cart?.discountCodes.map((item) => item.code),
1362
+ discount_code: discountCodes,
1359
1363
  user_tags: customer?.tags || []
1360
1364
  })
1361
1365
  }
1362
- ];
1366
+ ] : [];
1363
1367
  }, [cart]);
1364
1368
  const presellAttributes = react.useMemo(() => {
1365
1369
  return [