@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.
package/dist/index.js CHANGED
@@ -1447,15 +1447,19 @@ var useCartAttributes = ({
1447
1447
  ];
1448
1448
  }, [profile?.memberType, profile?.token, userType, hasPlusMember]);
1449
1449
  const functionAttributes = react.useMemo(() => {
1450
- return [
1451
- cart?.discountCodes && {
1450
+ const hasFunctionEnvAttribute = cart?.lineItems.some(
1451
+ (item) => item.customAttributes?.some((attr) => attr.key === CUSTOMER_ATTRIBUTE_KEY)
1452
+ );
1453
+ const discountCodes = cart?.discountCodes.map((item) => item.code).filter((code) => code) || [];
1454
+ return hasFunctionEnvAttribute ? [
1455
+ {
1452
1456
  key: "_discounts_function_env",
1453
1457
  value: JSON.stringify({
1454
- discount_code: cart?.discountCodes.map((item) => item.code),
1458
+ discount_code: discountCodes,
1455
1459
  user_tags: customer?.tags || []
1456
1460
  })
1457
1461
  }
1458
- ];
1462
+ ] : [];
1459
1463
  }, [cart]);
1460
1464
  const presellAttributes = react.useMemo(() => {
1461
1465
  return [