@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.
package/dist/index.mjs CHANGED
@@ -1439,15 +1439,19 @@ var useCartAttributes = ({
1439
1439
  ];
1440
1440
  }, [profile?.memberType, profile?.token, userType, hasPlusMember]);
1441
1441
  const functionAttributes = useMemo(() => {
1442
- return [
1443
- cart?.discountCodes && {
1442
+ const hasFunctionEnvAttribute = cart?.lineItems.some(
1443
+ (item) => item.customAttributes?.some((attr) => attr.key === CUSTOMER_ATTRIBUTE_KEY)
1444
+ );
1445
+ const discountCodes = cart?.discountCodes.map((item) => item.code).filter((code) => code) || [];
1446
+ return hasFunctionEnvAttribute ? [
1447
+ {
1444
1448
  key: "_discounts_function_env",
1445
1449
  value: JSON.stringify({
1446
- discount_code: cart?.discountCodes.map((item) => item.code),
1450
+ discount_code: discountCodes,
1447
1451
  user_tags: customer?.tags || []
1448
1452
  })
1449
1453
  }
1450
- ];
1454
+ ] : [];
1451
1455
  }, [cart]);
1452
1456
  const presellAttributes = useMemo(() => {
1453
1457
  return [