@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.
@@ -1568,7 +1568,17 @@ function getCartBasicAttributes({
1568
1568
  const presellAttributes = [
1569
1569
  {
1570
1570
  key: "_presale",
1571
- value: cart?.lineItems?.some((item) => item?.variant?.metafields?.presell === "presell") ? "true" : "false"
1571
+ value: cart?.lineItems?.some(
1572
+ (item) => item?.variant?.metafields?.global?.presell === "presell"
1573
+ ) ? "true" : "false"
1574
+ }
1575
+ ];
1576
+ const hideShippingAttributes = [
1577
+ {
1578
+ key: "_hide_shipping",
1579
+ value: cart?.lineItems?.some(
1580
+ (item) => item?.variant?.metafields?.global?.hideShipping === "true"
1581
+ ) ? "true" : "false"
1572
1582
  }
1573
1583
  ];
1574
1584
  const weightAttributes = [
@@ -1607,6 +1617,7 @@ function getCartBasicAttributes({
1607
1617
  ...functionAttributes,
1608
1618
  ...presellAttributes,
1609
1619
  ...weightAttributes,
1620
+ ...hideShippingAttributes,
1610
1621
  ...trackingAttributes,
1611
1622
  ...getReferralAttributes()
1612
1623
  ].filter((item) => item?.value !== void 0 && item?.value !== null);
@@ -2603,7 +2614,13 @@ function useBuyNow({ withTrack = true } = {}, swrOptions) {
2603
2614
  cookieAdapter: cartCookieAdapter,
2604
2615
  buyerIdentity,
2605
2616
  discountCodes,
2606
- customAttributes: [...basicCartAttributes, ...ga4Attributes, ...customAttributes || []]
2617
+ customAttributes: [
2618
+ ...basicCartAttributes.filter(
2619
+ (a) => !(customAttributes || []).some((c) => c.key === a.key)
2620
+ ),
2621
+ ...ga4Attributes.filter((a) => !(customAttributes || []).some((c) => c.key === a.key)),
2622
+ ...customAttributes || []
2623
+ ]
2607
2624
  });
2608
2625
  if (!resultCart) {
2609
2626
  throw new Error("Failed to create cart for buy now");
@@ -2611,7 +2628,9 @@ function useBuyNow({ withTrack = true } = {}, swrOptions) {
2611
2628
  if (withTrack && resultCart.lineItems) {
2612
2629
  trackBuyNowGA({
2613
2630
  lineItems: lineItems.map((item) => {
2614
- const cartLine = resultCart.lineItems.find((line) => line.variant.id === item.variant?.id);
2631
+ const cartLine = resultCart.lineItems.find(
2632
+ (line) => line.variant.id === item.variant?.id
2633
+ );
2615
2634
  if (!cartLine) {
2616
2635
  return null;
2617
2636
  }