@anker-in/shopify-react 0.1.1-beta.6 → 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.
@@ -1342,15 +1342,19 @@ var useCartAttributes = ({
1342
1342
  ];
1343
1343
  }, [profile?.memberType, profile?.token, userType, hasPlusMember]);
1344
1344
  const functionAttributes = useMemo(() => {
1345
- return [
1346
- cart?.discountCodes && {
1345
+ const hasFunctionEnvAttribute = cart?.lineItems.some(
1346
+ (item) => item.customAttributes?.some((attr) => attr.key === CUSTOMER_ATTRIBUTE_KEY)
1347
+ );
1348
+ const discountCodes = cart?.discountCodes.map((item) => item.code).filter((code) => code) || [];
1349
+ return hasFunctionEnvAttribute ? [
1350
+ {
1347
1351
  key: "_discounts_function_env",
1348
1352
  value: JSON.stringify({
1349
- discount_code: cart?.discountCodes.map((item) => item.code),
1353
+ discount_code: discountCodes,
1350
1354
  user_tags: customer?.tags || []
1351
1355
  })
1352
1356
  }
1353
- ];
1357
+ ] : [];
1354
1358
  }, [cart]);
1355
1359
  const presellAttributes = useMemo(() => {
1356
1360
  return [