@anker-in/shopify-react 0.1.1-beta.12 → 0.1.1-beta.14

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
@@ -977,7 +977,7 @@ function useRemoveCartCodes(options) {
977
977
  // src/hooks/cart/use-add-to-cart.ts
978
978
  function useAddToCart({ withTrack = true } = {}, swrOptions) {
979
979
  const { client, config, locale, cartCookieAdapter, userAdapter } = useShopify();
980
- const { cart } = useCartContext();
980
+ const { cart, addCustomAttributes } = useCartContext();
981
981
  const { trigger: applyCartCodes } = useApplyCartCodes();
982
982
  const { trigger: removeInvalidCodes } = useRemoveCartCodes();
983
983
  const { trigger: addCartLines2 } = useAddCartLines();
@@ -991,7 +991,8 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
991
991
  buyerIdentity,
992
992
  needCreateCart = false,
993
993
  onCodesInvalid,
994
- replaceExistingCodes
994
+ replaceExistingCodes,
995
+ customAttributes
995
996
  } = arg;
996
997
  if (!lineItems || lineItems.length === 0) {
997
998
  return;
@@ -1036,6 +1037,9 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
1036
1037
  discountCodes
1037
1038
  });
1038
1039
  }
1040
+ if (customAttributes && customAttributes.length > 0) {
1041
+ addCustomAttributes(customAttributes);
1042
+ }
1039
1043
  if (withTrack) {
1040
1044
  trackAddToCartGA({
1041
1045
  lineItems,
@@ -2662,9 +2666,9 @@ function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
2662
2666
  // src/hooks/member/plus/use-update-plus-member-delivery-options.ts
2663
2667
  var useUpdatePlusMemberDeliveryOptions = ({
2664
2668
  options
2665
- }) => {
2669
+ } = {}) => {
2666
2670
  const { cart: cartContextData, mutateCart, metafieldIdentifiers } = useCartContext();
2667
- const { trigger: updateCartDeliveryOptions2, isMutating } = useUpdateCartDeliveryOptions(
2671
+ const { trigger: updateCartDeliveryOptions2 } = useUpdateCartDeliveryOptions(
2668
2672
  mutateCart,
2669
2673
  metafieldIdentifiers
2670
2674
  );
@@ -2674,11 +2678,13 @@ var useUpdatePlusMemberDeliveryOptions = ({
2674
2678
  const { deliveryData } = arg;
2675
2679
  const firstDeliveryGroup = currentCart?.deliveryGroups?.[0];
2676
2680
  const deliveryGroupId = firstDeliveryGroup?.id;
2677
- const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option?.code;
2681
+ const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option;
2678
2682
  if (!deliveryGroupId || !selectedOptionCode || selectedOptionCode === firstDeliveryGroup?.selectedDeliveryOption?.code) {
2679
2683
  return null;
2680
2684
  }
2681
- const deliveryGroup = currentCart?.deliveryGroups?.find((group) => group?.id === deliveryGroupId);
2685
+ const deliveryGroup = currentCart?.deliveryGroups?.find(
2686
+ (group) => group?.id === deliveryGroupId
2687
+ );
2682
2688
  const matchedOption = deliveryGroup?.deliveryOptions?.find(
2683
2689
  (option) => option?.code === selectedOptionCode
2684
2690
  );
@@ -2797,7 +2803,7 @@ function useAddPlusMemberProductsToCart({
2797
2803
  if (profile?.isMonthlyPlus && selectedPlusMemberMode === "monthly" /* MONTHLY */) {
2798
2804
  return void 0;
2799
2805
  }
2800
- if (!profile?.isAnnualPlus && selectedPlusMemberMode === "annual" /* ANNUAL */) {
2806
+ if (profile?.isAnnualPlus && selectedPlusMemberMode === "annual" /* ANNUAL */) {
2801
2807
  return void 0;
2802
2808
  }
2803
2809
  return selectedPlusMemberProduct;
@@ -3117,7 +3123,7 @@ function CartProvider({
3117
3123
  useRequest(
3118
3124
  () => {
3119
3125
  const newAttributes = [...attributes, ...customAttributes];
3120
- const needUpdate = cart && !checkAttributesUpdateNeeded(
3126
+ const needUpdate = cart && checkAttributesUpdateNeeded(
3121
3127
  cart.customAttributes,
3122
3128
  newAttributes,
3123
3129
  customAttributesNeedDelete