@shopify/hydrogen 2026.1.4 → 2026.4.1

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.
@@ -443,7 +443,8 @@ function useCustomerPrivacy(props) {
443
443
  react.useEffect(() => {
444
444
  if (observing.current.customerPrivacy) return;
445
445
  observing.current.customerPrivacy = true;
446
- let customCustomerPrivacy = null;
446
+ let backendConsentStub = null;
447
+ let fullCustomerPrivacy = null;
447
448
  let customShopify = window.Shopify || void 0;
448
449
  Object.defineProperty(window, "Shopify", {
449
450
  configurable: true,
@@ -453,15 +454,16 @@ function useCustomerPrivacy(props) {
453
454
  set(value) {
454
455
  if (typeof value === "object" && value !== null && Object.keys(value).length === 0) {
455
456
  customShopify = value;
457
+ backendConsentStub = { backendConsentEnabled: true };
456
458
  Object.defineProperty(window.Shopify, "customerPrivacy", {
457
459
  configurable: true,
458
460
  get() {
459
- return customCustomerPrivacy;
461
+ return fullCustomerPrivacy ?? backendConsentStub;
460
462
  },
461
463
  set(value2) {
462
464
  if (typeof value2 === "object" && value2 !== null && "setTrackingConsent" in value2) {
463
465
  const customerPrivacy = value2;
464
- customCustomerPrivacy = {
466
+ fullCustomerPrivacy = {
465
467
  ...customerPrivacy,
466
468
  // Note: this method is not used by the privacy-banner,
467
469
  // it bundles its own setTrackingConsent.
@@ -471,7 +473,7 @@ function useCustomerPrivacy(props) {
471
473
  };
472
474
  customShopify = {
473
475
  ...customShopify,
474
- customerPrivacy: customCustomerPrivacy
476
+ customerPrivacy: fullCustomerPrivacy
475
477
  };
476
478
  setLoaded.customerPrivacy();
477
479
  }
@@ -596,7 +598,8 @@ function overridePrivacyBannerMethods({
596
598
  }
597
599
  function getCustomerPrivacy() {
598
600
  try {
599
- return window.Shopify && window.Shopify.customerPrivacy ? window.Shopify?.customerPrivacy : null;
601
+ const cp = window.Shopify?.customerPrivacy;
602
+ return cp && "setTrackingConsent" in cp ? cp : null;
600
603
  } catch (e) {
601
604
  return null;
602
605
  }
@@ -610,7 +613,7 @@ function getPrivacyBanner() {
610
613
  }
611
614
 
612
615
  // package.json
613
- var version = "2026.1.4";
616
+ var version = "2026.4.1";
614
617
 
615
618
  // src/analytics-manager/ShopifyAnalytics.tsx
616
619
  function getCustomerPrivacyRequired() {
@@ -1133,7 +1136,7 @@ function register(key) {
1133
1136
  }
1134
1137
  function shopifyCanTrack() {
1135
1138
  try {
1136
- return window.Shopify.customerPrivacy.analyticsProcessingAllowed();
1139
+ return window.Shopify.customerPrivacy?.analyticsProcessingAllowed?.() ?? false;
1137
1140
  } catch (e) {
1138
1141
  }
1139
1142
  return false;
@@ -2006,7 +2009,7 @@ function generateUUID() {
2006
2009
  }
2007
2010
 
2008
2011
  // src/version.ts
2009
- var LIB_VERSION = "2026.1.4";
2012
+ var LIB_VERSION = "2026.4.1";
2010
2013
 
2011
2014
  // src/utils/graphql.ts
2012
2015
  function minifyQuery(string) {
@@ -2534,6 +2537,20 @@ function formatAPIResult(data, errors2) {
2534
2537
  };
2535
2538
  }
2536
2539
 
2540
+ // src/cart/queries/cart-query-helpers.ts
2541
+ function shouldIncludeVisitorConsent(input) {
2542
+ return input?.visitorConsent !== void 0;
2543
+ }
2544
+ function getInContextVariables(includeVisitorConsent = false) {
2545
+ const base = `$country: CountryCode = ZZ
2546
+ $language: LanguageCode`;
2547
+ return includeVisitorConsent ? `${base}
2548
+ $visitorConsent: VisitorConsent` : base;
2549
+ }
2550
+ function getInContextDirective(includeVisitorConsent = false) {
2551
+ return includeVisitorConsent ? "@inContext(country: $country, language: $language, visitorConsent: $visitorConsent)" : "@inContext(country: $country, language: $language)";
2552
+ }
2553
+
2537
2554
  // src/cart/queries/cartGetDefault.ts
2538
2555
  function cartGetDefault({
2539
2556
  storefront,
@@ -2544,12 +2561,16 @@ function cartGetDefault({
2544
2561
  return async (cartInput) => {
2545
2562
  const cartId = getCartId();
2546
2563
  if (!cartId) return null;
2564
+ const includeVisitorConsent = shouldIncludeVisitorConsent(cartInput);
2547
2565
  const [isCustomerLoggedIn, { cart, errors: errors2 }] = await Promise.all([
2548
2566
  customerAccount ? customerAccount.isLoggedIn() : false,
2549
- storefront.query(CART_QUERY(cartFragment), {
2550
- variables: { cartId, ...cartInput },
2551
- cache: storefront.CacheNone()
2552
- })
2567
+ storefront.query(
2568
+ CART_QUERY(cartFragment, { includeVisitorConsent }),
2569
+ {
2570
+ variables: { cartId, ...cartInput },
2571
+ cache: storefront.CacheNone()
2572
+ }
2573
+ )
2553
2574
  ]);
2554
2575
  if (isCustomerLoggedIn && cart?.checkoutUrl) {
2555
2576
  const finalCheckoutUrl = new URL(cart.checkoutUrl);
@@ -2559,14 +2580,12 @@ function cartGetDefault({
2559
2580
  return cart || errors2 ? formatAPIResult(cart, errors2) : null;
2560
2581
  };
2561
2582
  }
2562
- var CART_QUERY = (cartFragment = DEFAULT_CART_FRAGMENT) => `#graphql
2583
+ var CART_QUERY = (cartFragment = DEFAULT_CART_FRAGMENT, options = {}) => `#graphql
2563
2584
  query CartQuery(
2564
2585
  $cartId: ID!
2565
2586
  $numCartLines: Int = 100
2566
- $country: CountryCode = ZZ
2567
- $language: LanguageCode
2568
- $visitorConsent: VisitorConsent
2569
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
2587
+ ${getInContextVariables(options.includeVisitorConsent)}
2588
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
2570
2589
  cart(id: $cartId) {
2571
2590
  ...CartApiQuery
2572
2591
  }
@@ -2720,7 +2739,8 @@ function cartCreateDefault(options) {
2720
2739
  const buyer = options.customerAccount ? await options.customerAccount.getBuyer() : void 0;
2721
2740
  const { cartId, ...restOfOptionalParams } = optionalParams || {};
2722
2741
  const { buyerIdentity, ...restOfInput } = input;
2723
- const { cartCreate, errors: errors2 } = await options.storefront.mutate(CART_CREATE_MUTATION(options.cartFragment), {
2742
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
2743
+ const { cartCreate, errors: errors2 } = await options.storefront.mutate(CART_CREATE_MUTATION(options.cartFragment, { includeVisitorConsent }), {
2724
2744
  variables: {
2725
2745
  input: {
2726
2746
  ...restOfInput,
@@ -2735,13 +2755,11 @@ function cartCreateDefault(options) {
2735
2755
  return formatAPIResult(cartCreate, errors2);
2736
2756
  };
2737
2757
  }
2738
- var CART_CREATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
2758
+ var CART_CREATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
2739
2759
  mutation cartCreate(
2740
2760
  $input: CartInput!
2741
- $country: CountryCode = ZZ
2742
- $language: LanguageCode
2743
- $visitorConsent: VisitorConsent
2744
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
2761
+ ${getInContextVariables(options.includeVisitorConsent)}
2762
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
2745
2763
  cartCreate(input: $input) {
2746
2764
  cart {
2747
2765
  ...CartApiMutation
@@ -2763,7 +2781,8 @@ var CART_CREATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
2763
2781
  // src/cart/queries/cartLinesAddDefault.ts
2764
2782
  function cartLinesAddDefault(options) {
2765
2783
  return async (lines, optionalParams) => {
2766
- const { cartLinesAdd, errors: errors2 } = await options.storefront.mutate(CART_LINES_ADD_MUTATION(options.cartFragment), {
2784
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
2785
+ const { cartLinesAdd, errors: errors2 } = await options.storefront.mutate(CART_LINES_ADD_MUTATION(options.cartFragment, { includeVisitorConsent }), {
2767
2786
  variables: {
2768
2787
  cartId: options.getCartId(),
2769
2788
  lines,
@@ -2773,14 +2792,12 @@ function cartLinesAddDefault(options) {
2773
2792
  return formatAPIResult(cartLinesAdd, errors2);
2774
2793
  };
2775
2794
  }
2776
- var CART_LINES_ADD_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
2795
+ var CART_LINES_ADD_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
2777
2796
  mutation cartLinesAdd(
2778
2797
  $cartId: ID!
2779
2798
  $lines: [CartLineInput!]!
2780
- $country: CountryCode = ZZ
2781
- $language: LanguageCode
2782
- $visitorConsent: VisitorConsent
2783
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
2799
+ ${getInContextVariables(options.includeVisitorConsent)}
2800
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
2784
2801
  cartLinesAdd(cartId: $cartId, lines: $lines) {
2785
2802
  cart {
2786
2803
  ...CartApiMutation
@@ -2820,24 +2837,26 @@ function throwIfLinesAreOptimistic(type, lines) {
2820
2837
  function cartLinesUpdateDefault(options) {
2821
2838
  return async (lines, optionalParams) => {
2822
2839
  throwIfLinesAreOptimistic("updateLines", lines);
2823
- const { cartLinesUpdate, errors: errors2 } = await options.storefront.mutate(CART_LINES_UPDATE_MUTATION(options.cartFragment), {
2824
- variables: {
2825
- cartId: options.getCartId(),
2826
- lines,
2827
- ...optionalParams
2840
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
2841
+ const { cartLinesUpdate, errors: errors2 } = await options.storefront.mutate(
2842
+ CART_LINES_UPDATE_MUTATION(options.cartFragment, { includeVisitorConsent }),
2843
+ {
2844
+ variables: {
2845
+ cartId: options.getCartId(),
2846
+ lines,
2847
+ ...optionalParams
2848
+ }
2828
2849
  }
2829
- });
2850
+ );
2830
2851
  return formatAPIResult(cartLinesUpdate, errors2);
2831
2852
  };
2832
2853
  }
2833
- var CART_LINES_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
2854
+ var CART_LINES_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
2834
2855
  mutation cartLinesUpdate(
2835
2856
  $cartId: ID!
2836
2857
  $lines: [CartLineUpdateInput!]!
2837
- $language: LanguageCode
2838
- $country: CountryCode
2839
- $visitorConsent: VisitorConsent
2840
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
2858
+ ${getInContextVariables(options.includeVisitorConsent)}
2859
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
2841
2860
  cartLinesUpdate(cartId: $cartId, lines: $lines) {
2842
2861
  cart {
2843
2862
  ...CartApiMutation
@@ -2859,24 +2878,26 @@ var CART_LINES_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#gra
2859
2878
  function cartLinesRemoveDefault(options) {
2860
2879
  return async (lineIds, optionalParams) => {
2861
2880
  throwIfLinesAreOptimistic("removeLines", lineIds);
2862
- const { cartLinesRemove, errors: errors2 } = await options.storefront.mutate(CART_LINES_REMOVE_MUTATION(options.cartFragment), {
2863
- variables: {
2864
- cartId: options.getCartId(),
2865
- lineIds,
2866
- ...optionalParams
2881
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
2882
+ const { cartLinesRemove, errors: errors2 } = await options.storefront.mutate(
2883
+ CART_LINES_REMOVE_MUTATION(options.cartFragment, { includeVisitorConsent }),
2884
+ {
2885
+ variables: {
2886
+ cartId: options.getCartId(),
2887
+ lineIds,
2888
+ ...optionalParams
2889
+ }
2867
2890
  }
2868
- });
2891
+ );
2869
2892
  return formatAPIResult(cartLinesRemove, errors2);
2870
2893
  };
2871
2894
  }
2872
- var CART_LINES_REMOVE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
2895
+ var CART_LINES_REMOVE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
2873
2896
  mutation cartLinesRemove(
2874
2897
  $cartId: ID!
2875
2898
  $lineIds: [ID!]!
2876
- $language: LanguageCode
2877
- $country: CountryCode
2878
- $visitorConsent: VisitorConsent
2879
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
2899
+ ${getInContextVariables(options.includeVisitorConsent)}
2900
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
2880
2901
  cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
2881
2902
  cart {
2882
2903
  ...CartApiMutation
@@ -2900,24 +2921,28 @@ function cartDiscountCodesUpdateDefault(options) {
2900
2921
  const uniqueCodes = discountCodes.filter((value, index, array) => {
2901
2922
  return array.indexOf(value) === index;
2902
2923
  });
2903
- const { cartDiscountCodesUpdate, errors: errors2 } = await options.storefront.mutate(CART_DISCOUNT_CODE_UPDATE_MUTATION(options.cartFragment), {
2904
- variables: {
2905
- cartId: options.getCartId(),
2906
- discountCodes: uniqueCodes,
2907
- ...optionalParams
2924
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
2925
+ const { cartDiscountCodesUpdate, errors: errors2 } = await options.storefront.mutate(
2926
+ CART_DISCOUNT_CODE_UPDATE_MUTATION(options.cartFragment, {
2927
+ includeVisitorConsent
2928
+ }),
2929
+ {
2930
+ variables: {
2931
+ cartId: options.getCartId(),
2932
+ discountCodes: uniqueCodes,
2933
+ ...optionalParams
2934
+ }
2908
2935
  }
2909
- });
2936
+ );
2910
2937
  return formatAPIResult(cartDiscountCodesUpdate, errors2);
2911
2938
  };
2912
2939
  }
2913
- var CART_DISCOUNT_CODE_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
2940
+ var CART_DISCOUNT_CODE_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
2914
2941
  mutation cartDiscountCodesUpdate(
2915
2942
  $cartId: ID!
2916
2943
  $discountCodes: [String!]!
2917
- $language: LanguageCode
2918
- $country: CountryCode
2919
- $visitorConsent: VisitorConsent
2920
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
2944
+ ${getInContextVariables(options.includeVisitorConsent)}
2945
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
2921
2946
  cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
2922
2947
  ... @defer {
2923
2948
  cart {
@@ -2946,27 +2971,31 @@ function cartBuyerIdentityUpdateDefault(options) {
2946
2971
  });
2947
2972
  }
2948
2973
  const buyer = options.customerAccount ? await options.customerAccount.getBuyer() : void 0;
2949
- const { cartBuyerIdentityUpdate, errors: errors2 } = await options.storefront.mutate(CART_BUYER_IDENTITY_UPDATE_MUTATION(options.cartFragment), {
2950
- variables: {
2951
- cartId: options.getCartId(),
2952
- buyerIdentity: {
2953
- ...buyer,
2954
- ...buyerIdentity
2955
- },
2956
- ...optionalParams
2974
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
2975
+ const { cartBuyerIdentityUpdate, errors: errors2 } = await options.storefront.mutate(
2976
+ CART_BUYER_IDENTITY_UPDATE_MUTATION(options.cartFragment, {
2977
+ includeVisitorConsent
2978
+ }),
2979
+ {
2980
+ variables: {
2981
+ cartId: options.getCartId(),
2982
+ buyerIdentity: {
2983
+ ...buyer,
2984
+ ...buyerIdentity
2985
+ },
2986
+ ...optionalParams
2987
+ }
2957
2988
  }
2958
- });
2989
+ );
2959
2990
  return formatAPIResult(cartBuyerIdentityUpdate, errors2);
2960
2991
  };
2961
2992
  }
2962
- var CART_BUYER_IDENTITY_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
2993
+ var CART_BUYER_IDENTITY_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
2963
2994
  mutation cartBuyerIdentityUpdate(
2964
2995
  $cartId: ID!
2965
2996
  $buyerIdentity: CartBuyerIdentityInput!
2966
- $language: LanguageCode
2967
- $country: CountryCode
2968
- $visitorConsent: VisitorConsent
2969
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
2997
+ ${getInContextVariables(options.includeVisitorConsent)}
2998
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
2970
2999
  cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
2971
3000
  cart {
2972
3001
  ...CartApiMutation
@@ -2987,24 +3016,26 @@ var CART_BUYER_IDENTITY_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT)
2987
3016
  // src/cart/queries/cartNoteUpdateDefault.ts
2988
3017
  function cartNoteUpdateDefault(options) {
2989
3018
  return async (note, optionalParams) => {
2990
- const { cartNoteUpdate, errors: errors2 } = await options.storefront.mutate(CART_NOTE_UPDATE_MUTATION(options.cartFragment), {
2991
- variables: {
2992
- cartId: options.getCartId(),
2993
- note,
2994
- ...optionalParams
3019
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3020
+ const { cartNoteUpdate, errors: errors2 } = await options.storefront.mutate(
3021
+ CART_NOTE_UPDATE_MUTATION(options.cartFragment, { includeVisitorConsent }),
3022
+ {
3023
+ variables: {
3024
+ cartId: options.getCartId(),
3025
+ note,
3026
+ ...optionalParams
3027
+ }
2995
3028
  }
2996
- });
3029
+ );
2997
3030
  return formatAPIResult(cartNoteUpdate, errors2);
2998
3031
  };
2999
3032
  }
3000
- var CART_NOTE_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
3033
+ var CART_NOTE_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
3001
3034
  mutation cartNoteUpdate(
3002
3035
  $cartId: ID!
3003
3036
  $note: String!
3004
- $language: LanguageCode
3005
- $country: CountryCode
3006
- $visitorConsent: VisitorConsent
3007
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3037
+ ${getInContextVariables(options.includeVisitorConsent)}
3038
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3008
3039
  cartNoteUpdate(cartId: $cartId, note: $note) {
3009
3040
  cart {
3010
3041
  ...CartApiMutation
@@ -3025,24 +3056,28 @@ var CART_NOTE_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#grap
3025
3056
  // src/cart/queries/cartSelectedDeliveryOptionsUpdateDefault.ts
3026
3057
  function cartSelectedDeliveryOptionsUpdateDefault(options) {
3027
3058
  return async (selectedDeliveryOptions, optionalParams) => {
3028
- const { cartSelectedDeliveryOptionsUpdate, errors: errors2 } = await options.storefront.mutate(CART_SELECTED_DELIVERY_OPTIONS_UPDATE_MUTATION(options.cartFragment), {
3029
- variables: {
3030
- cartId: options.getCartId(),
3031
- selectedDeliveryOptions,
3032
- ...optionalParams
3059
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3060
+ const { cartSelectedDeliveryOptionsUpdate, errors: errors2 } = await options.storefront.mutate(
3061
+ CART_SELECTED_DELIVERY_OPTIONS_UPDATE_MUTATION(options.cartFragment, {
3062
+ includeVisitorConsent
3063
+ }),
3064
+ {
3065
+ variables: {
3066
+ cartId: options.getCartId(),
3067
+ selectedDeliveryOptions,
3068
+ ...optionalParams
3069
+ }
3033
3070
  }
3034
- });
3071
+ );
3035
3072
  return formatAPIResult(cartSelectedDeliveryOptionsUpdate, errors2);
3036
3073
  };
3037
3074
  }
3038
- var CART_SELECTED_DELIVERY_OPTIONS_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
3075
+ var CART_SELECTED_DELIVERY_OPTIONS_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
3039
3076
  mutation cartSelectedDeliveryOptionsUpdate(
3040
3077
  $cartId: ID!
3041
3078
  $selectedDeliveryOptions: [CartSelectedDeliveryOptionInput!]!
3042
- $language: LanguageCode
3043
- $country: CountryCode
3044
- $visitorConsent: VisitorConsent
3045
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3079
+ ${getInContextVariables(options.includeVisitorConsent)}
3080
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3046
3081
  cartSelectedDeliveryOptionsUpdate(cartId: $cartId, selectedDeliveryOptions: $selectedDeliveryOptions) {
3047
3082
  cart {
3048
3083
  ...CartApiMutation
@@ -3063,24 +3098,28 @@ var CART_SELECTED_DELIVERY_OPTIONS_UPDATE_MUTATION = (cartFragment = MINIMAL_CAR
3063
3098
  // src/cart/queries/cartAttributesUpdateDefault.ts
3064
3099
  function cartAttributesUpdateDefault(options) {
3065
3100
  return async (attributes, optionalParams) => {
3066
- const { cartAttributesUpdate, errors: errors2 } = await options.storefront.mutate(CART_ATTRIBUTES_UPDATE_MUTATION(options.cartFragment), {
3067
- variables: {
3068
- cartId: optionalParams?.cartId || options.getCartId(),
3069
- attributes,
3070
- ...optionalParams
3101
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3102
+ const { cartAttributesUpdate, errors: errors2 } = await options.storefront.mutate(
3103
+ CART_ATTRIBUTES_UPDATE_MUTATION(options.cartFragment, {
3104
+ includeVisitorConsent
3105
+ }),
3106
+ {
3107
+ variables: {
3108
+ cartId: optionalParams?.cartId || options.getCartId(),
3109
+ attributes,
3110
+ ...optionalParams
3111
+ }
3071
3112
  }
3072
- });
3113
+ );
3073
3114
  return formatAPIResult(cartAttributesUpdate, errors2);
3074
3115
  };
3075
3116
  }
3076
- var CART_ATTRIBUTES_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
3117
+ var CART_ATTRIBUTES_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
3077
3118
  mutation cartAttributesUpdate(
3078
3119
  $cartId: ID!
3079
3120
  $attributes: [AttributeInput!]!
3080
- $language: LanguageCode
3081
- $country: CountryCode
3082
- $visitorConsent: VisitorConsent
3083
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3121
+ ${getInContextVariables(options.includeVisitorConsent)}
3122
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3084
3123
  cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {
3085
3124
  cart {
3086
3125
  ...CartApiMutation
@@ -3108,7 +3147,8 @@ function cartMetafieldsSetDefault(options) {
3108
3147
  ownerId
3109
3148
  })
3110
3149
  );
3111
- const { cartMetafieldsSet, errors: errors2 } = await options.storefront.mutate(CART_METAFIELD_SET_MUTATION(), {
3150
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3151
+ const { cartMetafieldsSet, errors: errors2 } = await options.storefront.mutate(CART_METAFIELD_SET_MUTATION({ includeVisitorConsent }), {
3112
3152
  variables: { metafields: metafieldsWithOwnerId, ...optionalParams }
3113
3153
  });
3114
3154
  return formatAPIResult(
@@ -3122,13 +3162,11 @@ function cartMetafieldsSetDefault(options) {
3122
3162
  );
3123
3163
  };
3124
3164
  }
3125
- var CART_METAFIELD_SET_MUTATION = () => `#graphql
3165
+ var CART_METAFIELD_SET_MUTATION = (options = {}) => `#graphql
3126
3166
  mutation cartMetafieldsSet(
3127
3167
  $metafields: [CartMetafieldsSetInput!]!
3128
- $language: LanguageCode
3129
- $country: CountryCode
3130
- $visitorConsent: VisitorConsent
3131
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3168
+ ${getInContextVariables(options.includeVisitorConsent)}
3169
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3132
3170
  cartMetafieldsSet(metafields: $metafields) {
3133
3171
  userErrors {
3134
3172
  code
@@ -3144,7 +3182,8 @@ var CART_METAFIELD_SET_MUTATION = () => `#graphql
3144
3182
  function cartMetafieldDeleteDefault(options) {
3145
3183
  return async (key, optionalParams) => {
3146
3184
  const ownerId = optionalParams?.cartId || options.getCartId();
3147
- const { cartMetafieldDelete, errors: errors2 } = await options.storefront.mutate(CART_METAFIELD_DELETE_MUTATION(), {
3185
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3186
+ const { cartMetafieldDelete, errors: errors2 } = await options.storefront.mutate(CART_METAFIELD_DELETE_MUTATION({ includeVisitorConsent }), {
3148
3187
  variables: {
3149
3188
  input: {
3150
3189
  ownerId,
@@ -3164,13 +3203,11 @@ function cartMetafieldDeleteDefault(options) {
3164
3203
  );
3165
3204
  };
3166
3205
  }
3167
- var CART_METAFIELD_DELETE_MUTATION = () => `#graphql
3206
+ var CART_METAFIELD_DELETE_MUTATION = (options = {}) => `#graphql
3168
3207
  mutation cartMetafieldDelete(
3169
3208
  $input: CartMetafieldDeleteInput!
3170
- $language: LanguageCode
3171
- $country: CountryCode
3172
- $visitorConsent: VisitorConsent
3173
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3209
+ ${getInContextVariables(options.includeVisitorConsent)}
3210
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3174
3211
  cartMetafieldDelete(input: $input) {
3175
3212
  userErrors {
3176
3213
  code
@@ -3184,24 +3221,28 @@ var CART_METAFIELD_DELETE_MUTATION = () => `#graphql
3184
3221
  // src/cart/queries/cartGiftCardCodeUpdateDefault.ts
3185
3222
  function cartGiftCardCodesUpdateDefault(options) {
3186
3223
  return async (giftCardCodes, optionalParams) => {
3187
- const { cartGiftCardCodesUpdate, errors: errors2 } = await options.storefront.mutate(CART_GIFT_CARD_CODE_UPDATE_MUTATION(options.cartFragment), {
3188
- variables: {
3189
- cartId: options.getCartId(),
3190
- giftCardCodes,
3191
- ...optionalParams
3224
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3225
+ const { cartGiftCardCodesUpdate, errors: errors2 } = await options.storefront.mutate(
3226
+ CART_GIFT_CARD_CODE_UPDATE_MUTATION(options.cartFragment, {
3227
+ includeVisitorConsent
3228
+ }),
3229
+ {
3230
+ variables: {
3231
+ cartId: options.getCartId(),
3232
+ giftCardCodes,
3233
+ ...optionalParams
3234
+ }
3192
3235
  }
3193
- });
3236
+ );
3194
3237
  return formatAPIResult(cartGiftCardCodesUpdate, errors2);
3195
3238
  };
3196
3239
  }
3197
- var CART_GIFT_CARD_CODE_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
3240
+ var CART_GIFT_CARD_CODE_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
3198
3241
  mutation cartGiftCardCodesUpdate(
3199
3242
  $cartId: ID!
3200
3243
  $giftCardCodes: [String!]!
3201
- $language: LanguageCode
3202
- $country: CountryCode
3203
- $visitorConsent: VisitorConsent
3204
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3244
+ ${getInContextVariables(options.includeVisitorConsent)}
3245
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3205
3246
  cartGiftCardCodesUpdate(cartId: $cartId, giftCardCodes: $giftCardCodes) {
3206
3247
  cart {
3207
3248
  ...CartApiMutation
@@ -3259,24 +3300,28 @@ var CART_GIFT_CARD_CODES_ADD_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) =
3259
3300
  // src/cart/queries/cartGiftCardCodesRemoveDefault.ts
3260
3301
  function cartGiftCardCodesRemoveDefault(options) {
3261
3302
  return async (appliedGiftCardIds, optionalParams) => {
3262
- const { cartGiftCardCodesRemove, errors: errors2 } = await options.storefront.mutate(CART_GIFT_CARD_CODES_REMOVE_MUTATION(options.cartFragment), {
3263
- variables: {
3264
- cartId: options.getCartId(),
3265
- appliedGiftCardIds,
3266
- ...optionalParams
3303
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3304
+ const { cartGiftCardCodesRemove, errors: errors2 } = await options.storefront.mutate(
3305
+ CART_GIFT_CARD_CODES_REMOVE_MUTATION(options.cartFragment, {
3306
+ includeVisitorConsent
3307
+ }),
3308
+ {
3309
+ variables: {
3310
+ cartId: options.getCartId(),
3311
+ appliedGiftCardIds,
3312
+ ...optionalParams
3313
+ }
3267
3314
  }
3268
- });
3315
+ );
3269
3316
  return formatAPIResult(cartGiftCardCodesRemove, errors2);
3270
3317
  };
3271
3318
  }
3272
- var CART_GIFT_CARD_CODES_REMOVE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
3319
+ var CART_GIFT_CARD_CODES_REMOVE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
3273
3320
  mutation cartGiftCardCodesRemove(
3274
3321
  $cartId: ID!
3275
3322
  $appliedGiftCardIds: [ID!]!
3276
- $language: LanguageCode
3277
- $country: CountryCode
3278
- $visitorConsent: VisitorConsent
3279
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3323
+ ${getInContextVariables(options.includeVisitorConsent)}
3324
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3280
3325
  cartGiftCardCodesRemove(cartId: $cartId, appliedGiftCardIds: $appliedGiftCardIds) {
3281
3326
  cart {
3282
3327
  ...CartApiMutation
@@ -3297,24 +3342,28 @@ var CART_GIFT_CARD_CODES_REMOVE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT
3297
3342
  // src/cart/queries/cartDeliveryAddressesAddDefault.tsx
3298
3343
  function cartDeliveryAddressesAddDefault(options) {
3299
3344
  return async (addresses, optionalParams) => {
3300
- const { cartDeliveryAddressesAdd, errors: errors2 } = await options.storefront.mutate(CART_DELIVERY_ADDRESSES_ADD_MUTATION(options.cartFragment), {
3301
- variables: {
3302
- cartId: options.getCartId(),
3303
- addresses,
3304
- ...optionalParams
3345
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3346
+ const { cartDeliveryAddressesAdd, errors: errors2 } = await options.storefront.mutate(
3347
+ CART_DELIVERY_ADDRESSES_ADD_MUTATION(options.cartFragment, {
3348
+ includeVisitorConsent
3349
+ }),
3350
+ {
3351
+ variables: {
3352
+ cartId: options.getCartId(),
3353
+ addresses,
3354
+ ...optionalParams
3355
+ }
3305
3356
  }
3306
- });
3357
+ );
3307
3358
  return formatAPIResult(cartDeliveryAddressesAdd, errors2);
3308
3359
  };
3309
3360
  }
3310
- var CART_DELIVERY_ADDRESSES_ADD_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
3361
+ var CART_DELIVERY_ADDRESSES_ADD_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
3311
3362
  mutation cartDeliveryAddressesAdd(
3312
3363
  $cartId: ID!
3313
3364
  $addresses: [CartSelectableAddressInput!]!,
3314
- $country: CountryCode = ZZ
3315
- $language: LanguageCode
3316
- $visitorConsent: VisitorConsent
3317
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3365
+ ${getInContextVariables(options.includeVisitorConsent)}
3366
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3318
3367
  cartDeliveryAddressesAdd(addresses: $addresses, cartId: $cartId) {
3319
3368
  cart {
3320
3369
  ...CartApiMutation
@@ -3335,24 +3384,28 @@ var CART_DELIVERY_ADDRESSES_ADD_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT
3335
3384
  // src/cart/queries/cartDeliveryAddressesRemoveDefault.tsx
3336
3385
  function cartDeliveryAddressesRemoveDefault(options) {
3337
3386
  return async (addressIds, optionalParams) => {
3338
- const { cartDeliveryAddressesRemove, errors: errors2 } = await options.storefront.mutate(CART_DELIVERY_ADDRESSES_REMOVE_MUTATION(options.cartFragment), {
3339
- variables: {
3340
- cartId: options.getCartId(),
3341
- addressIds,
3342
- ...optionalParams
3387
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3388
+ const { cartDeliveryAddressesRemove, errors: errors2 } = await options.storefront.mutate(
3389
+ CART_DELIVERY_ADDRESSES_REMOVE_MUTATION(options.cartFragment, {
3390
+ includeVisitorConsent
3391
+ }),
3392
+ {
3393
+ variables: {
3394
+ cartId: options.getCartId(),
3395
+ addressIds,
3396
+ ...optionalParams
3397
+ }
3343
3398
  }
3344
- });
3399
+ );
3345
3400
  return formatAPIResult(cartDeliveryAddressesRemove, errors2);
3346
3401
  };
3347
3402
  }
3348
- var CART_DELIVERY_ADDRESSES_REMOVE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
3403
+ var CART_DELIVERY_ADDRESSES_REMOVE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
3349
3404
  mutation cartDeliveryAddressesRemove(
3350
3405
  $cartId: ID!
3351
3406
  $addressIds: [ID!]!,
3352
- $country: CountryCode = ZZ
3353
- $language: LanguageCode
3354
- $visitorConsent: VisitorConsent
3355
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3407
+ ${getInContextVariables(options.includeVisitorConsent)}
3408
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3356
3409
  cartDeliveryAddressesRemove(addressIds: $addressIds, cartId: $cartId) {
3357
3410
  cart {
3358
3411
  ...CartApiMutation
@@ -3373,24 +3426,28 @@ var CART_DELIVERY_ADDRESSES_REMOVE_MUTATION = (cartFragment = MINIMAL_CART_FRAGM
3373
3426
  // src/cart/queries/cartDeliveryAddressesUpdateDefault.tsx
3374
3427
  function cartDeliveryAddressesUpdateDefault(options) {
3375
3428
  return async (addresses, optionalParams) => {
3376
- const { cartDeliveryAddressesUpdate, errors: errors2 } = await options.storefront.mutate(CART_DELIVERY_ADDRESSES_UPDATE_MUTATION(options.cartFragment), {
3377
- variables: {
3378
- cartId: options.getCartId(),
3379
- addresses,
3380
- ...optionalParams
3429
+ const includeVisitorConsent = shouldIncludeVisitorConsent(optionalParams);
3430
+ const { cartDeliveryAddressesUpdate, errors: errors2 } = await options.storefront.mutate(
3431
+ CART_DELIVERY_ADDRESSES_UPDATE_MUTATION(options.cartFragment, {
3432
+ includeVisitorConsent
3433
+ }),
3434
+ {
3435
+ variables: {
3436
+ cartId: options.getCartId(),
3437
+ addresses,
3438
+ ...optionalParams
3439
+ }
3381
3440
  }
3382
- });
3441
+ );
3383
3442
  return formatAPIResult(cartDeliveryAddressesUpdate, errors2);
3384
3443
  };
3385
3444
  }
3386
- var CART_DELIVERY_ADDRESSES_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT) => `#graphql
3445
+ var CART_DELIVERY_ADDRESSES_UPDATE_MUTATION = (cartFragment = MINIMAL_CART_FRAGMENT, options = {}) => `#graphql
3387
3446
  mutation cartDeliveryAddressesUpdate(
3388
3447
  $cartId: ID!
3389
3448
  $addresses: [CartSelectableAddressUpdateInput!]!,
3390
- $country: CountryCode = ZZ
3391
- $language: LanguageCode
3392
- $visitorConsent: VisitorConsent
3393
- ) @inContext(country: $country, language: $language, visitorConsent: $visitorConsent) {
3449
+ ${getInContextVariables(options.includeVisitorConsent)}
3450
+ ) ${getInContextDirective(options.includeVisitorConsent)} {
3394
3451
  cartDeliveryAddressesUpdate(addresses: $addresses, cartId: $cartId) {
3395
3452
  cart {
3396
3453
  ...CartApiMutation
@@ -3661,7 +3718,7 @@ var hydrogenContext = {
3661
3718
  };
3662
3719
 
3663
3720
  // src/customer/constants.ts
3664
- var DEFAULT_CUSTOMER_API_VERSION = "2026-01";
3721
+ var DEFAULT_CUSTOMER_API_VERSION = "2026-04";
3665
3722
  var USER_AGENT = `Shopify Hydrogen ${LIB_VERSION}`;
3666
3723
  var CUSTOMER_API_CLIENT_ID = "30243aa5-17c1-465a-8493-944bcc4e88aa";
3667
3724
  var CUSTOMER_ACCOUNT_SESSION_KEY = "customerAccount";
@@ -3939,15 +3996,15 @@ function ensureLocalRedirectUrl({
3939
3996
  redirectUrl
3940
3997
  }) {
3941
3998
  const fromUrl = requestUrl;
3942
- const defautlUrl = buildURLObject(requestUrl, defaultUrl);
3943
- const toUrl = redirectUrl ? buildURLObject(requestUrl, redirectUrl) : defautlUrl;
3999
+ const parsedDefaultUrl = buildURLObject(requestUrl, defaultUrl);
4000
+ const toUrl = redirectUrl ? buildURLObject(requestUrl, redirectUrl) : parsedDefaultUrl;
3944
4001
  if (isLocalPath(requestUrl, toUrl.toString())) {
3945
4002
  return toUrl.toString();
3946
4003
  } else {
3947
4004
  console.warn(
3948
- `Cross-domain redirects are not supported. Tried to redirect from ${fromUrl} to ${toUrl}. Default url ${defautlUrl} is used instead.`
4005
+ `Cross-domain redirects are not supported. Tried to redirect from ${fromUrl} to ${toUrl}. Default url ${parsedDefaultUrl} is used instead.`
3949
4006
  );
3950
- return defautlUrl.toString();
4007
+ return parsedDefaultUrl.toString();
3951
4008
  }
3952
4009
  }
3953
4010
  function buildURLObject(requestUrl, relativeOrAbsoluteUrl) {
@@ -4588,8 +4645,7 @@ function createRequestHandler({
4588
4645
  mode,
4589
4646
  poweredByHeader = true,
4590
4647
  getLoadContext,
4591
- collectTrackingInformation = true,
4592
- proxyStandardRoutes = true
4648
+ collectTrackingInformation = true
4593
4649
  }) {
4594
4650
  const handleRequest = reactRouter.createRequestHandler(build, mode);
4595
4651
  const appendPoweredByHeader = poweredByHeader ? (response) => response.headers.append("powered-by", "Shopify, Hydrogen") : void 0;
@@ -4611,32 +4667,28 @@ function createRequestHandler({
4611
4667
  }
4612
4668
  const context = await getLoadContext?.(request);
4613
4669
  const storefront = context?.storefront || context?.get?.(storefrontContext);
4614
- if (proxyStandardRoutes) {
4615
- if (!storefront) {
4616
- warnOnce(
4617
- "[h2:createRequestHandler] Storefront instance is required to proxy standard routes."
4618
- );
4619
- }
4620
- if (storefront?.isStorefrontApiUrl(request)) {
4621
- const response2 = await storefront.forward(request);
4622
- appendPoweredByHeader?.(response2);
4623
- return response2;
4624
- }
4625
- if (storefront?.isMcpUrl(request)) {
4626
- const response2 = await storefront.forwardMcp(request);
4627
- appendPoweredByHeader?.(response2);
4628
- return response2;
4629
- }
4670
+ if (!storefront) {
4671
+ throw new Error(
4672
+ "[h2:createRequestHandler] Storefront instance is required in the load context. Make sure to use createHydrogenContext() or provide a storefront instance via getLoadContext."
4673
+ );
4674
+ }
4675
+ if (storefront.isStorefrontApiUrl(request)) {
4676
+ const response2 = await storefront.forward(request);
4677
+ appendPoweredByHeader?.(response2);
4678
+ return response2;
4679
+ }
4680
+ if (storefront.isMcpUrl(request)) {
4681
+ const response2 = await storefront.forwardMcp(request);
4682
+ appendPoweredByHeader?.(response2);
4683
+ return response2;
4630
4684
  }
4631
4685
  const response = await handleRequest(request, context);
4632
- if (storefront && proxyStandardRoutes) {
4633
- if (collectTrackingInformation) {
4634
- storefront.setCollectedSubrequestHeaders(response);
4635
- }
4636
- const fetchDest = request.headers.get("sec-fetch-dest");
4637
- if (fetchDest && fetchDest === "document" || request.headers.get("accept")?.includes("text/html")) {
4638
- appendServerTimingHeader(response, { [HYDROGEN_SFAPI_PROXY_KEY]: "1" });
4639
- }
4686
+ if (collectTrackingInformation) {
4687
+ storefront.setCollectedSubrequestHeaders(response);
4688
+ }
4689
+ const fetchDest = request.headers.get("sec-fetch-dest");
4690
+ if (fetchDest && fetchDest === "document" || request.headers.get("accept")?.includes("text/html")) {
4691
+ appendServerTimingHeader(response, { [HYDROGEN_SFAPI_PROXY_KEY]: "1" });
4640
4692
  }
4641
4693
  appendPoweredByHeader?.(response);
4642
4694
  return response;
@@ -6676,14 +6728,14 @@ var QUERIES = {
6676
6728
  //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartNoteUpdate
6677
6729
  //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartSelectedDeliveryOptionsUpdate
6678
6730
  //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet
6679
- //! @see https://shopify.dev/docs/api/storefront/2026-01/mutations/cartMetafieldDelete
6731
+ //! @see https://shopify.dev/docs/api/storefront/2026-04/mutations/cartMetafieldDelete
6680
6732
  //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartGiftCardCodesUpdate
6681
6733
  //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartGiftCardCodesAdd
6682
6734
  //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartGiftCardCodesRemove
6683
6735
  //! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartDeliveryAddressesAdd
6684
6736
  //! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartDeliveryAddressesRemove
6685
6737
  //! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartDeliveryAddressesUpdate
6686
- //! @see: https://shopify.dev/docs/api/storefront/2026-01/mutations/cartDeliveryAddressesReplace
6738
+ //! @see: https://shopify.dev/docs/api/storefront/2026-04/mutations/cartDeliveryAddressesReplace
6687
6739
 
6688
6740
  Object.defineProperty(exports, "AnalyticsEventName", {
6689
6741
  enumerable: true,