@anker-in/shopify-react 1.2.8 → 1.2.9-beta.2

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
@@ -1729,7 +1729,17 @@ function getCartBasicAttributes({
1729
1729
  const presellAttributes = [
1730
1730
  {
1731
1731
  key: "_presale",
1732
- value: cart?.lineItems?.some((item) => item?.variant?.metafields?.presell === "presell") ? "true" : "false"
1732
+ value: cart?.lineItems?.some(
1733
+ (item) => item?.variant?.metafields?.global?.presell === "presell"
1734
+ ) ? "true" : "false"
1735
+ }
1736
+ ];
1737
+ const hideShippingAttributes = [
1738
+ {
1739
+ key: "_hide_shipping",
1740
+ value: cart?.lineItems?.some(
1741
+ (item) => item?.variant?.metafields?.global?.hideShipping === "true"
1742
+ ) ? "true" : "false"
1733
1743
  }
1734
1744
  ];
1735
1745
  const weightAttributes = [
@@ -1768,6 +1778,7 @@ function getCartBasicAttributes({
1768
1778
  ...functionAttributes,
1769
1779
  ...presellAttributes,
1770
1780
  ...weightAttributes,
1781
+ ...hideShippingAttributes,
1771
1782
  ...trackingAttributes,
1772
1783
  ...getReferralAttributes()
1773
1784
  ].filter((item) => item?.value !== void 0 && item?.value !== null);
@@ -2764,7 +2775,13 @@ function useBuyNow({ withTrack = true } = {}, swrOptions) {
2764
2775
  cookieAdapter: cartCookieAdapter,
2765
2776
  buyerIdentity,
2766
2777
  discountCodes,
2767
- customAttributes: [...basicCartAttributes, ...ga4Attributes, ...customAttributes || []]
2778
+ customAttributes: [
2779
+ ...basicCartAttributes.filter(
2780
+ (a) => !(customAttributes || []).some((c) => c.key === a.key)
2781
+ ),
2782
+ ...ga4Attributes.filter((a) => !(customAttributes || []).some((c) => c.key === a.key)),
2783
+ ...customAttributes || []
2784
+ ]
2768
2785
  });
2769
2786
  if (!resultCart) {
2770
2787
  throw new Error("Failed to create cart for buy now");
@@ -2772,7 +2789,9 @@ function useBuyNow({ withTrack = true } = {}, swrOptions) {
2772
2789
  if (withTrack && resultCart.lineItems) {
2773
2790
  trackBuyNowGA({
2774
2791
  lineItems: lineItems.map((item) => {
2775
- const cartLine = resultCart.lineItems.find((line) => line.variant.id === item.variant?.id);
2792
+ const cartLine = resultCart.lineItems.find(
2793
+ (line) => line.variant.id === item.variant?.id
2794
+ );
2776
2795
  if (!cartLine) {
2777
2796
  return null;
2778
2797
  }