@shopify/hydrogen-react 2023.7.3 → 2023.7.5
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/browser-dev/CartProvider.mjs +4 -1
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/cart-queries.mjs +18 -9
- package/dist/browser-dev/cart-queries.mjs.map +1 -1
- package/dist/browser-dev/cookies-utils.mjs +1 -1
- package/dist/browser-dev/cookies-utils.mjs.map +1 -1
- package/dist/browser-dev/load-script.mjs +6 -0
- package/dist/browser-dev/load-script.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs +4 -2
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-dev/useCartActions.mjs +29 -19
- package/dist/browser-dev/useCartActions.mjs.map +1 -1
- package/dist/browser-prod/CartProvider.mjs +4 -1
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/cart-queries.mjs +18 -9
- package/dist/browser-prod/cart-queries.mjs.map +1 -1
- package/dist/browser-prod/cookies-utils.mjs +1 -1
- package/dist/browser-prod/cookies-utils.mjs.map +1 -1
- package/dist/browser-prod/load-script.mjs +6 -0
- package/dist/browser-prod/load-script.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs +4 -2
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/useCartActions.mjs +29 -19
- package/dist/browser-prod/useCartActions.mjs.map +1 -1
- package/dist/node-dev/CartProvider.js +4 -1
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs +4 -1
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/cart-queries.js +18 -9
- package/dist/node-dev/cart-queries.js.map +1 -1
- package/dist/node-dev/cart-queries.mjs +18 -9
- package/dist/node-dev/cart-queries.mjs.map +1 -1
- package/dist/node-dev/cookies-utils.js +1 -1
- package/dist/node-dev/cookies-utils.js.map +1 -1
- package/dist/node-dev/cookies-utils.mjs +1 -1
- package/dist/node-dev/cookies-utils.mjs.map +1 -1
- package/dist/node-dev/load-script.js +6 -0
- package/dist/node-dev/load-script.js.map +1 -1
- package/dist/node-dev/load-script.mjs +6 -0
- package/dist/node-dev/load-script.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js +4 -2
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs +4 -2
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/useCartActions.js +29 -19
- package/dist/node-dev/useCartActions.js.map +1 -1
- package/dist/node-dev/useCartActions.mjs +29 -19
- package/dist/node-dev/useCartActions.mjs.map +1 -1
- package/dist/node-prod/CartProvider.js +4 -1
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs +4 -1
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/cart-queries.js +18 -9
- package/dist/node-prod/cart-queries.js.map +1 -1
- package/dist/node-prod/cart-queries.mjs +18 -9
- package/dist/node-prod/cart-queries.mjs.map +1 -1
- package/dist/node-prod/cookies-utils.js +1 -1
- package/dist/node-prod/cookies-utils.js.map +1 -1
- package/dist/node-prod/cookies-utils.mjs +1 -1
- package/dist/node-prod/cookies-utils.mjs.map +1 -1
- package/dist/node-prod/load-script.js +6 -0
- package/dist/node-prod/load-script.js.map +1 -1
- package/dist/node-prod/load-script.mjs +6 -0
- package/dist/node-prod/load-script.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js +4 -2
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs +4 -2
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/useCartActions.js +29 -19
- package/dist/node-prod/useCartActions.js.map +1 -1
- package/dist/node-prod/useCartActions.mjs +29 -19
- package/dist/node-prod/useCartActions.mjs.map +1 -1
- package/dist/types/CartProvider.d.ts +4 -2
- package/dist/types/load-script.d.ts +4 -2
- package/dist/types/useCartAPIStateMachine.d.ts +4 -2
- package/dist/types/useCartActions.d.ts +5 -3
- package/dist/umd/hydrogen-react.dev.js +62 -32
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +35 -26
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +36 -4
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
type LoadScriptOptions = {
|
|
2
2
|
module?: boolean;
|
|
3
3
|
in?: 'head' | 'body';
|
|
4
|
-
|
|
4
|
+
attributes?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
export declare function loadScript(src: string, options?: LoadScriptOptions): Promise<boolean>;
|
|
5
7
|
type LoadScriptParams = Parameters<typeof loadScript>;
|
|
6
8
|
/**
|
|
7
9
|
* The `useLoadScript` hook loads an external script tag in the browser. It allows React components to lazy-load large third-party dependencies.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StateMachine } from '@xstate/fsm';
|
|
2
2
|
import { Cart, CartMachineActionEvent, CartMachineContext, CartMachineEvent, CartMachineFetchResultEvent, CartMachineTypeState } from './cart-types.js';
|
|
3
|
-
import { CountryCode, Cart as CartType } from './storefront-api-types.js';
|
|
3
|
+
import { CountryCode, Cart as CartType, LanguageCode } from './storefront-api-types.js';
|
|
4
4
|
import type { PartialDeep } from 'type-fest';
|
|
5
|
-
export declare function useCartAPIStateMachine({ numCartLines, onCartActionEntry, onCartActionOptimisticUI, onCartActionComplete, data: cart, cartFragment, countryCode, }: {
|
|
5
|
+
export declare function useCartAPIStateMachine({ numCartLines, onCartActionEntry, onCartActionOptimisticUI, onCartActionComplete, data: cart, cartFragment, countryCode, languageCode, }: {
|
|
6
6
|
/** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */
|
|
7
7
|
numCartLines?: number;
|
|
8
8
|
/** A callback that is invoked just before a Cart API action executes. */
|
|
@@ -19,6 +19,8 @@ export declare function useCartAPIStateMachine({ numCartLines, onCartActionEntry
|
|
|
19
19
|
cartFragment: string;
|
|
20
20
|
/** The ISO country code for i18n. */
|
|
21
21
|
countryCode?: CountryCode;
|
|
22
|
+
/** The ISO language code for i18n. */
|
|
23
|
+
languageCode?: LanguageCode;
|
|
22
24
|
}): readonly [StateMachine.State<CartMachineContext, CartMachineEvent, CartMachineTypeState>, (event: "CART_FETCH" | "CART_CREATE" | "CART_SET" | "CARTLINE_ADD" | "CARTLINE_REMOVE" | "CARTLINE_UPDATE" | "NOTE_UPDATE" | "BUYER_IDENTITY_UPDATE" | "CART_ATTRIBUTES_UPDATE" | "DISCOUNT_CODES_UPDATE" | "CART_COMPLETED" | "RESOLVE" | "ERROR" | CartMachineEvent) => void, StateMachine.Service<CartMachineContext, CartMachineEvent, CartMachineTypeState>];
|
|
23
25
|
export declare function cartFromGraphQL(cart: PartialDeep<CartType, {
|
|
24
26
|
recurseIntoArrays: true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AttributeInput, CartBuyerIdentityInput, CartInput, CartLineInput, CartLineUpdateInput, CountryCode, Cart as CartType, MutationCartDiscountCodesUpdateArgs, MutationCartNoteUpdateArgs } from './storefront-api-types.js';
|
|
1
|
+
import { AttributeInput, CartBuyerIdentityInput, CartInput, CartLineInput, CartLineUpdateInput, CountryCode, LanguageCode, Cart as CartType, MutationCartDiscountCodesUpdateArgs, MutationCartNoteUpdateArgs } from './storefront-api-types.js';
|
|
2
2
|
import { PartialDeep } from 'type-fest';
|
|
3
3
|
type CartResponse = PartialDeep<CartType, {
|
|
4
4
|
recurseIntoArrays: true;
|
|
@@ -8,13 +8,15 @@ type CartResponse = PartialDeep<CartType, {
|
|
|
8
8
|
*
|
|
9
9
|
* See [cart API graphql mutations](https://shopify.dev/api/storefront/2023-07/objects/Cart)
|
|
10
10
|
*/
|
|
11
|
-
export declare function useCartActions({ numCartLines, cartFragment, countryCode, }: {
|
|
11
|
+
export declare function useCartActions({ numCartLines, cartFragment, countryCode, languageCode, }: {
|
|
12
12
|
/** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */
|
|
13
13
|
numCartLines?: number;
|
|
14
14
|
/** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/2023-07/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */
|
|
15
15
|
cartFragment: string;
|
|
16
|
-
/** The ISO country code for i18n. */
|
|
16
|
+
/** The ISO country code for i18n. Default to `US` */
|
|
17
17
|
countryCode?: CountryCode;
|
|
18
|
+
/** The ISO language code for i18n. Default to `EN` */
|
|
19
|
+
languageCode?: LanguageCode;
|
|
18
20
|
}): {
|
|
19
21
|
cartFetch: (cartId: string) => Promise<import("./storefront-api-response.types.js").StorefrontApiResponseOkPartial<{
|
|
20
22
|
cart: CartResponse;
|
|
@@ -523,7 +523,8 @@
|
|
|
523
523
|
$lines: [CartLineInput!]!
|
|
524
524
|
$numCartLines: Int = 250
|
|
525
525
|
$country: CountryCode = ZZ
|
|
526
|
-
|
|
526
|
+
$language: LanguageCode
|
|
527
|
+
) @inContext(country: $country, language: $language) {
|
|
527
528
|
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
528
529
|
cart {
|
|
529
530
|
...CartFragment
|
|
@@ -541,7 +542,8 @@
|
|
|
541
542
|
$input: CartInput!
|
|
542
543
|
$numCartLines: Int = 250
|
|
543
544
|
$country: CountryCode = ZZ
|
|
544
|
-
|
|
545
|
+
$language: LanguageCode
|
|
546
|
+
) @inContext(country: $country, language: $language) {
|
|
545
547
|
cartCreate(input: $input) {
|
|
546
548
|
cart {
|
|
547
549
|
...CartFragment
|
|
@@ -560,7 +562,8 @@
|
|
|
560
562
|
$lines: [ID!]!
|
|
561
563
|
$numCartLines: Int = 250
|
|
562
564
|
$country: CountryCode = ZZ
|
|
563
|
-
|
|
565
|
+
$language: LanguageCode
|
|
566
|
+
) @inContext(country: $country, language: $language) {
|
|
564
567
|
cartLinesRemove(cartId: $cartId, lineIds: $lines) {
|
|
565
568
|
cart {
|
|
566
569
|
...CartFragment
|
|
@@ -579,7 +582,8 @@
|
|
|
579
582
|
$lines: [CartLineUpdateInput!]!
|
|
580
583
|
$numCartLines: Int = 250
|
|
581
584
|
$country: CountryCode = ZZ
|
|
582
|
-
|
|
585
|
+
$language: LanguageCode
|
|
586
|
+
) @inContext(country: $country, language: $language) {
|
|
583
587
|
cartLinesUpdate(cartId: $cartId, lines: $lines) {
|
|
584
588
|
cart {
|
|
585
589
|
...CartFragment
|
|
@@ -598,7 +602,8 @@
|
|
|
598
602
|
$note: String
|
|
599
603
|
$numCartLines: Int = 250
|
|
600
604
|
$country: CountryCode = ZZ
|
|
601
|
-
|
|
605
|
+
$language: LanguageCode
|
|
606
|
+
) @inContext(country: $country, language: $language) {
|
|
602
607
|
cartNoteUpdate(cartId: $cartId, note: $note) {
|
|
603
608
|
cart {
|
|
604
609
|
...CartFragment
|
|
@@ -617,7 +622,8 @@
|
|
|
617
622
|
$buyerIdentity: CartBuyerIdentityInput!
|
|
618
623
|
$numCartLines: Int = 250
|
|
619
624
|
$country: CountryCode = ZZ
|
|
620
|
-
|
|
625
|
+
$language: LanguageCode
|
|
626
|
+
) @inContext(country: $country, language: $language) {
|
|
621
627
|
cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
|
|
622
628
|
cart {
|
|
623
629
|
...CartFragment
|
|
@@ -636,7 +642,8 @@
|
|
|
636
642
|
$cartId: ID!
|
|
637
643
|
$numCartLines: Int = 250
|
|
638
644
|
$country: CountryCode = ZZ
|
|
639
|
-
|
|
645
|
+
$language: LanguageCode
|
|
646
|
+
) @inContext(country: $country, language: $language) {
|
|
640
647
|
cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
|
|
641
648
|
cart {
|
|
642
649
|
...CartFragment
|
|
@@ -655,7 +662,8 @@
|
|
|
655
662
|
$discountCodes: [String!]
|
|
656
663
|
$numCartLines: Int = 250
|
|
657
664
|
$country: CountryCode = ZZ
|
|
658
|
-
|
|
665
|
+
$language: LanguageCode
|
|
666
|
+
) @inContext(country: $country, language: $language) {
|
|
659
667
|
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
660
668
|
cart {
|
|
661
669
|
...CartFragment
|
|
@@ -673,7 +681,8 @@
|
|
|
673
681
|
$id: ID!
|
|
674
682
|
$numCartLines: Int = 250
|
|
675
683
|
$country: CountryCode = ZZ
|
|
676
|
-
|
|
684
|
+
$language: LanguageCode
|
|
685
|
+
) @inContext(country: $country, language: $language) {
|
|
677
686
|
cart(id: $id) {
|
|
678
687
|
...CartFragment
|
|
679
688
|
}
|
|
@@ -1019,7 +1028,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1019
1028
|
perfNumber = 0;
|
|
1020
1029
|
}
|
|
1021
1030
|
const output = Math.abs(dateNumber + perfNumber).toString(16).toLowerCase();
|
|
1022
|
-
return output.padStart(8
|
|
1031
|
+
return output.padStart(8, "0");
|
|
1023
1032
|
}
|
|
1024
1033
|
function getShopifyCookies(cookies) {
|
|
1025
1034
|
const cookieData = u(cookies);
|
|
@@ -1065,7 +1074,8 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1065
1074
|
function useCartActions({
|
|
1066
1075
|
numCartLines,
|
|
1067
1076
|
cartFragment,
|
|
1068
|
-
countryCode = "US"
|
|
1077
|
+
countryCode = "US",
|
|
1078
|
+
languageCode = "EN"
|
|
1069
1079
|
}) {
|
|
1070
1080
|
const fetchCart = useCartFetch();
|
|
1071
1081
|
const cartFetch = React$1.useCallback(
|
|
@@ -1075,11 +1085,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1075
1085
|
variables: {
|
|
1076
1086
|
id: cartId,
|
|
1077
1087
|
numCartLines,
|
|
1078
|
-
country: countryCode
|
|
1088
|
+
country: countryCode,
|
|
1089
|
+
language: languageCode
|
|
1079
1090
|
}
|
|
1080
1091
|
});
|
|
1081
1092
|
},
|
|
1082
|
-
[fetchCart, cartFragment, numCartLines, countryCode]
|
|
1093
|
+
[fetchCart, cartFragment, numCartLines, countryCode, languageCode]
|
|
1083
1094
|
);
|
|
1084
1095
|
const cartCreate = React$1.useCallback(
|
|
1085
1096
|
(cart) => {
|
|
@@ -1088,11 +1099,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1088
1099
|
variables: {
|
|
1089
1100
|
input: cart,
|
|
1090
1101
|
numCartLines,
|
|
1091
|
-
country: countryCode
|
|
1102
|
+
country: countryCode,
|
|
1103
|
+
language: languageCode
|
|
1092
1104
|
}
|
|
1093
1105
|
});
|
|
1094
1106
|
},
|
|
1095
|
-
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1107
|
+
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
|
|
1096
1108
|
);
|
|
1097
1109
|
const cartLineAdd = React$1.useCallback(
|
|
1098
1110
|
(cartId, lines) => {
|
|
@@ -1102,11 +1114,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1102
1114
|
cartId,
|
|
1103
1115
|
lines,
|
|
1104
1116
|
numCartLines,
|
|
1105
|
-
country: countryCode
|
|
1117
|
+
country: countryCode,
|
|
1118
|
+
language: languageCode
|
|
1106
1119
|
}
|
|
1107
1120
|
});
|
|
1108
1121
|
},
|
|
1109
|
-
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1122
|
+
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
|
|
1110
1123
|
);
|
|
1111
1124
|
const cartLineUpdate = React$1.useCallback(
|
|
1112
1125
|
(cartId, lines) => {
|
|
@@ -1116,11 +1129,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1116
1129
|
cartId,
|
|
1117
1130
|
lines,
|
|
1118
1131
|
numCartLines,
|
|
1119
|
-
country: countryCode
|
|
1132
|
+
country: countryCode,
|
|
1133
|
+
language: languageCode
|
|
1120
1134
|
}
|
|
1121
1135
|
});
|
|
1122
1136
|
},
|
|
1123
|
-
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1137
|
+
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
|
|
1124
1138
|
);
|
|
1125
1139
|
const cartLineRemove = React$1.useCallback(
|
|
1126
1140
|
(cartId, lines) => {
|
|
@@ -1130,11 +1144,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1130
1144
|
cartId,
|
|
1131
1145
|
lines,
|
|
1132
1146
|
numCartLines,
|
|
1133
|
-
country: countryCode
|
|
1147
|
+
country: countryCode,
|
|
1148
|
+
language: languageCode
|
|
1134
1149
|
}
|
|
1135
1150
|
});
|
|
1136
1151
|
},
|
|
1137
|
-
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1152
|
+
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
|
|
1138
1153
|
);
|
|
1139
1154
|
const noteUpdate = React$1.useCallback(
|
|
1140
1155
|
(cartId, note) => {
|
|
@@ -1144,11 +1159,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1144
1159
|
cartId,
|
|
1145
1160
|
note,
|
|
1146
1161
|
numCartLines,
|
|
1147
|
-
country: countryCode
|
|
1162
|
+
country: countryCode,
|
|
1163
|
+
language: languageCode
|
|
1148
1164
|
}
|
|
1149
1165
|
});
|
|
1150
1166
|
},
|
|
1151
|
-
[fetchCart, cartFragment, numCartLines, countryCode]
|
|
1167
|
+
[fetchCart, cartFragment, numCartLines, countryCode, languageCode]
|
|
1152
1168
|
);
|
|
1153
1169
|
const buyerIdentityUpdate = React$1.useCallback(
|
|
1154
1170
|
(cartId, buyerIdentity) => {
|
|
@@ -1158,11 +1174,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1158
1174
|
cartId,
|
|
1159
1175
|
buyerIdentity,
|
|
1160
1176
|
numCartLines,
|
|
1161
|
-
country: countryCode
|
|
1177
|
+
country: countryCode,
|
|
1178
|
+
language: languageCode
|
|
1162
1179
|
}
|
|
1163
1180
|
});
|
|
1164
1181
|
},
|
|
1165
|
-
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1182
|
+
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
|
|
1166
1183
|
);
|
|
1167
1184
|
const cartAttributesUpdate = React$1.useCallback(
|
|
1168
1185
|
(cartId, attributes) => {
|
|
@@ -1172,11 +1189,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1172
1189
|
cartId,
|
|
1173
1190
|
attributes,
|
|
1174
1191
|
numCartLines,
|
|
1175
|
-
country: countryCode
|
|
1192
|
+
country: countryCode,
|
|
1193
|
+
language: languageCode
|
|
1176
1194
|
}
|
|
1177
1195
|
});
|
|
1178
1196
|
},
|
|
1179
|
-
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1197
|
+
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
|
|
1180
1198
|
);
|
|
1181
1199
|
const discountCodesUpdate = React$1.useCallback(
|
|
1182
1200
|
(cartId, discountCodes) => {
|
|
@@ -1186,11 +1204,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1186
1204
|
cartId,
|
|
1187
1205
|
discountCodes,
|
|
1188
1206
|
numCartLines,
|
|
1189
|
-
country: countryCode
|
|
1207
|
+
country: countryCode,
|
|
1208
|
+
language: languageCode
|
|
1190
1209
|
}
|
|
1191
1210
|
});
|
|
1192
1211
|
},
|
|
1193
|
-
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1212
|
+
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
|
|
1194
1213
|
);
|
|
1195
1214
|
return React$1.useMemo(
|
|
1196
1215
|
() => ({
|
|
@@ -1367,7 +1386,8 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1367
1386
|
onCartActionComplete,
|
|
1368
1387
|
data: cart,
|
|
1369
1388
|
cartFragment,
|
|
1370
|
-
countryCode
|
|
1389
|
+
countryCode,
|
|
1390
|
+
languageCode
|
|
1371
1391
|
}) {
|
|
1372
1392
|
const {
|
|
1373
1393
|
cartFetch,
|
|
@@ -1382,7 +1402,8 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1382
1402
|
} = useCartActions({
|
|
1383
1403
|
numCartLines,
|
|
1384
1404
|
cartFragment,
|
|
1385
|
-
countryCode
|
|
1405
|
+
countryCode,
|
|
1406
|
+
languageCode
|
|
1386
1407
|
});
|
|
1387
1408
|
const cartMachine = React$1.useMemo(() => createCartMachine(cart), [cart]);
|
|
1388
1409
|
const [state, send, service] = useMachine(cartMachine, {
|
|
@@ -1608,7 +1629,8 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1608
1629
|
data: cart,
|
|
1609
1630
|
cartFragment = defaultCartFragment,
|
|
1610
1631
|
customerAccessToken,
|
|
1611
|
-
countryCode
|
|
1632
|
+
countryCode,
|
|
1633
|
+
languageCode
|
|
1612
1634
|
}) {
|
|
1613
1635
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1614
1636
|
const shop = useShop();
|
|
@@ -1617,6 +1639,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1617
1639
|
"<CartProvider> needs to be a descendant of <ShopifyProvider>"
|
|
1618
1640
|
);
|
|
1619
1641
|
countryCode = (countryCode ?? shop.countryIsoCode ?? "US").toUpperCase();
|
|
1642
|
+
languageCode = (languageCode ?? shop.languageIsoCode ?? "EN").toUpperCase();
|
|
1620
1643
|
if (countryCode)
|
|
1621
1644
|
countryCode = countryCode.toUpperCase();
|
|
1622
1645
|
const [prevCountryCode, setPrevCountryCode] = React$1.useState(countryCode);
|
|
@@ -1632,6 +1655,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
1632
1655
|
data: cart,
|
|
1633
1656
|
cartFragment,
|
|
1634
1657
|
countryCode,
|
|
1658
|
+
languageCode,
|
|
1635
1659
|
onCartActionEntry(_, event) {
|
|
1636
1660
|
try {
|
|
1637
1661
|
switch (event.type) {
|
|
@@ -3344,6 +3368,12 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
3344
3368
|
} else {
|
|
3345
3369
|
document.body.appendChild(script);
|
|
3346
3370
|
}
|
|
3371
|
+
const attributes = options == null ? void 0 : options.attributes;
|
|
3372
|
+
if (attributes) {
|
|
3373
|
+
Object.keys(attributes).forEach((key) => {
|
|
3374
|
+
script.setAttribute(key, attributes[key]);
|
|
3375
|
+
});
|
|
3376
|
+
}
|
|
3347
3377
|
});
|
|
3348
3378
|
SCRIPTS_LOADED[src] = promise;
|
|
3349
3379
|
return promise;
|