@rebuy/rebuy-hydrogen 2.3.1 → 3.0.0-beta.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.
- package/package.json +52 -26
- package/src/components/AddToCartBtn/AddToCartBtn.tsx +45 -0
- package/src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx +43 -0
- package/src/components/AddToCartBtn/HydrogenReactAddToCartBtn.tsx +35 -0
- package/src/components/AddToCartBtn/index.ts +1 -0
- package/src/components/AddToCartBtn/types.ts +27 -0
- package/src/components/ProductCard/ProductCard.tsx +70 -0
- package/src/components/ProductCard/index.ts +1 -0
- package/src/components/ProductCard/types.ts +10 -0
- package/src/components/ProductPrice/ProductPrice.tsx +49 -0
- package/src/components/ProductPrice/index.ts +1 -0
- package/src/components/Title/Title.tsx +20 -0
- package/src/components/Title/index.ts +1 -0
- package/src/components/Title/types.ts +7 -0
- package/src/components/VariantSelect/VariantSelect.tsx +45 -0
- package/src/components/VariantSelect/index.ts +1 -0
- package/src/components/VariantSelect/types.ts +6 -0
- package/src/context/RebuyContext.tsx +9 -0
- package/src/hooks/titleLevel.tsx +42 -0
- package/src/index.ts +7 -0
- package/src/providers/RebuyHydrogenContextProvider.tsx +112 -0
- package/src/providers/RebuyHydrogenReactContextProvider.tsx +192 -0
- package/src/providers/types.ts +58 -0
- package/src/queries/cart.queries.ts +467 -0
- package/src/types/common.ts +8 -0
- package/src/types/css.d.ts +11 -0
- package/src/types/env.d.ts +12 -0
- package/src/types/rebuy.d.ts +31 -0
- package/src/types/rebuyCustom.ts +263 -0
- package/src/types/rebuySmartCart.ts +188 -0
- package/src/types/shopify.ts +142 -0
- package/src/types/widgets.ts +29 -0
- package/src/utils/convertToRebuyProduct.tsx +319 -0
- package/src/utils/createContextParameters.ts +142 -0
- package/src/utils/getEncodedAttributes.ts +11 -0
- package/src/utils/getRebuyConfig.ts +31 -0
- package/src/widgetContainer/RebuyWidgetContainer.tsx +183 -0
- package/src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx +50 -0
- package/src/widgets/RebuyCompleteTheLook/index.ts +1 -0
- package/src/widgets/RebuyCompleteTheLook/types.ts +5 -0
- package/src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx +62 -0
- package/src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx +93 -0
- package/src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx +65 -0
- package/src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx +118 -0
- package/src/widgets/RebuyDynamicBundleProducts/Select.tsx +41 -0
- package/src/widgets/RebuyDynamicBundleProducts/index.ts +1 -0
- package/src/widgets/RebuyDynamicBundleProducts/types.ts +23 -0
- package/src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx +66 -0
- package/src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx +218 -0
- package/src/widgets/RebuyProductAddOns/index.ts +1 -0
- package/src/widgets/RebuyProductAddOns/types.ts +24 -0
- package/src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx +50 -0
- package/src/widgets/RebuyProductRecommendations/index.ts +1 -0
- package/src/widgets/RebuyProductRecommendations/types.ts +5 -0
- package/RebuyCompleteTheLook.client.jsx +0 -188
- package/RebuyContextProvider.client.jsx +0 -222
- package/RebuyContexts.client.jsx +0 -3
- package/RebuyDynamicBundleProducts.client.jsx +0 -415
- package/RebuyProductAddOnCard.client.jsx +0 -89
- package/RebuyProductAddOns.client.jsx +0 -227
- package/RebuyProductRecommendations.client.jsx +0 -68
- package/RebuyProductViewed.client.jsx +0 -62
- package/RebuyRecentlyViewedProducts.client.jsx +0 -68
- package/RebuyWidgetContainer.client.jsx +0 -136
@@ -0,0 +1,192 @@
|
|
1
|
+
import * as Utilities from '@rebuy/rebuy/utilities';
|
2
|
+
import { useLocation } from '@remix-run/react';
|
3
|
+
import {
|
4
|
+
CartProvider,
|
5
|
+
ShopifyProvider,
|
6
|
+
useCart,
|
7
|
+
} from '@shopify/hydrogen-react';
|
8
|
+
import { useEffect, useMemo, useState } from 'react';
|
9
|
+
|
10
|
+
import type { Attribute } from '@shopify/hydrogen-react/storefront-api-types';
|
11
|
+
import type {
|
12
|
+
RebuyHydrogenReactContextProviderProps,
|
13
|
+
RebuyHydrogenReactProps,
|
14
|
+
} from '~/providers/types';
|
15
|
+
import type { RebuyConfig } from '~/types/rebuyCustom';
|
16
|
+
|
17
|
+
import { RebuyContext } from '~/context/RebuyContext';
|
18
|
+
import { CART_FRAGMENT } from '~/queries/cart.queries';
|
19
|
+
import { createContextParameters } from '~/utils/createContextParameters';
|
20
|
+
import { getRebuyConfig } from '~/utils/getRebuyConfig';
|
21
|
+
|
22
|
+
const RebuyHydrogenReactContext = ({ children }: RebuyHydrogenReactProps) => {
|
23
|
+
const primaryDomain = import.meta.env.PRIMARY_DOMAIN;
|
24
|
+
const rebuyKey = import.meta.env.PUBLIC_REBUY_API_KEY;
|
25
|
+
const storeDomain = import.meta.env.PUBLIC_STORE_DOMAIN;
|
26
|
+
|
27
|
+
const [rebuyConfig, setRebuyConfig] = useState<RebuyConfig | null>(null);
|
28
|
+
const location = useLocation();
|
29
|
+
const queryObject = Utilities.queryStringToObject(location.search);
|
30
|
+
const windowUrl = `${primaryDomain}${location.pathname}${location.search}`;
|
31
|
+
|
32
|
+
// This is the cart object from Hydrogen-React
|
33
|
+
const cart = useCart();
|
34
|
+
|
35
|
+
// Initialization
|
36
|
+
useEffect(() => {
|
37
|
+
const initConfig = async () => {
|
38
|
+
const config = await getRebuyConfig(rebuyKey, storeDomain);
|
39
|
+
setRebuyConfig(config);
|
40
|
+
};
|
41
|
+
|
42
|
+
if (!rebuyConfig?.shop) {
|
43
|
+
initConfig();
|
44
|
+
}
|
45
|
+
}, [rebuyConfig, rebuyKey, storeDomain]);
|
46
|
+
|
47
|
+
const contextParameters = useMemo(
|
48
|
+
() =>
|
49
|
+
createContextParameters({
|
50
|
+
cacheKey: rebuyConfig?.shop?.cache_key,
|
51
|
+
cartAttributes: cart?.attributes as Attribute[],
|
52
|
+
cartId: cart?.id,
|
53
|
+
cartLines: cart?.lines,
|
54
|
+
cartLinesLength: cart?.lines?.length,
|
55
|
+
cartSubtotal: cart?.cost?.subtotalAmount?.amount,
|
56
|
+
cartTotalQuantity: cart?.totalQuantity,
|
57
|
+
isHydrogenReact: true,
|
58
|
+
queryObject,
|
59
|
+
windowUrl,
|
60
|
+
}),
|
61
|
+
[rebuyConfig, windowUrl, queryObject, cart]
|
62
|
+
);
|
63
|
+
|
64
|
+
// Static reference (JSON) + memoization
|
65
|
+
// ^ prevent re-rendering children when context params are unchanged
|
66
|
+
const contextParametersJSON = JSON.stringify(contextParameters);
|
67
|
+
const contextValue = useMemo(
|
68
|
+
() => ({ contextParameters: JSON.parse(contextParametersJSON) }),
|
69
|
+
[contextParametersJSON]
|
70
|
+
);
|
71
|
+
|
72
|
+
return (
|
73
|
+
<RebuyContext.Provider value={contextValue}>
|
74
|
+
{children}
|
75
|
+
</RebuyContext.Provider>
|
76
|
+
);
|
77
|
+
};
|
78
|
+
|
79
|
+
export const RebuyHydrogenReactContextProvider = ({
|
80
|
+
cartFragment = CART_FRAGMENT,
|
81
|
+
children,
|
82
|
+
countryIsoCode = 'US',
|
83
|
+
customerAccessToken = '',
|
84
|
+
data,
|
85
|
+
languageIsoCode = 'EN',
|
86
|
+
numCartLines,
|
87
|
+
onAttributesUpdate,
|
88
|
+
onAttributesUpdateComplete,
|
89
|
+
onBuyerIdentityUpdate,
|
90
|
+
onBuyerIdentityUpdateComplete,
|
91
|
+
onCreate,
|
92
|
+
onCreateComplete,
|
93
|
+
onDiscountCodesUpdate,
|
94
|
+
onDiscountCodesUpdateComplete,
|
95
|
+
onLineAdd,
|
96
|
+
onLineAddComplete,
|
97
|
+
onLineRemove,
|
98
|
+
onLineRemoveComplete,
|
99
|
+
onLineUpdate,
|
100
|
+
onLineUpdateComplete,
|
101
|
+
onNoteUpdate,
|
102
|
+
onNoteUpdateComplete,
|
103
|
+
storefrontApiVersion = '2025-01',
|
104
|
+
}: RebuyHydrogenReactContextProviderProps) => {
|
105
|
+
const publicStoreDomain = import.meta.env.PUBLIC_STORE_DOMAIN;
|
106
|
+
const storefrontId = import.meta.env.PUBLIC_STOREFRONT_ID;
|
107
|
+
const storefrontToken = import.meta.env.PUBLIC_STOREFRONT_API_TOKEN || '';
|
108
|
+
const adapted = {
|
109
|
+
onAttributesUpdate: onAttributesUpdate
|
110
|
+
? () => onAttributesUpdate()
|
111
|
+
: undefined,
|
112
|
+
onAttributesUpdateComplete: onAttributesUpdateComplete
|
113
|
+
? () => onAttributesUpdateComplete()
|
114
|
+
: undefined,
|
115
|
+
onBuyerIdentityUpdate: onBuyerIdentityUpdate
|
116
|
+
? () => onBuyerIdentityUpdate()
|
117
|
+
: undefined,
|
118
|
+
onBuyerIdentityUpdateComplete: onBuyerIdentityUpdateComplete
|
119
|
+
? () => onBuyerIdentityUpdateComplete()
|
120
|
+
: undefined,
|
121
|
+
onCreate: onCreate ? () => onCreate() : undefined,
|
122
|
+
onCreateComplete: onCreateComplete
|
123
|
+
? () => onCreateComplete()
|
124
|
+
: undefined,
|
125
|
+
onDiscountCodesUpdate: onDiscountCodesUpdate
|
126
|
+
? () => onDiscountCodesUpdate()
|
127
|
+
: undefined,
|
128
|
+
onDiscountCodesUpdateComplete: onDiscountCodesUpdateComplete
|
129
|
+
? () => onDiscountCodesUpdateComplete()
|
130
|
+
: undefined,
|
131
|
+
onLineAdd: onLineAdd ? () => onLineAdd() : undefined,
|
132
|
+
onLineAddComplete: onLineAddComplete
|
133
|
+
? () => onLineAddComplete()
|
134
|
+
: undefined,
|
135
|
+
onLineRemove: onLineRemove ? () => onLineRemove() : undefined,
|
136
|
+
onLineRemoveComplete: onLineRemoveComplete
|
137
|
+
? () => onLineRemoveComplete()
|
138
|
+
: undefined,
|
139
|
+
onLineUpdate: onLineUpdate ? () => onLineUpdate() : undefined,
|
140
|
+
onLineUpdateComplete: onLineUpdateComplete
|
141
|
+
? () => onLineUpdateComplete()
|
142
|
+
: undefined,
|
143
|
+
onNoteUpdate: onNoteUpdate ? () => onNoteUpdate() : undefined,
|
144
|
+
onNoteUpdateComplete: onNoteUpdateComplete
|
145
|
+
? () => onNoteUpdateComplete()
|
146
|
+
: undefined,
|
147
|
+
};
|
148
|
+
|
149
|
+
return (
|
150
|
+
<ShopifyProvider
|
151
|
+
countryIsoCode={countryIsoCode}
|
152
|
+
languageIsoCode={languageIsoCode}
|
153
|
+
storeDomain={publicStoreDomain}
|
154
|
+
storefrontApiVersion={storefrontApiVersion}
|
155
|
+
storefrontId={storefrontId}
|
156
|
+
storefrontToken={storefrontToken}
|
157
|
+
>
|
158
|
+
<CartProvider
|
159
|
+
cartFragment={cartFragment}
|
160
|
+
countryCode={countryIsoCode}
|
161
|
+
customerAccessToken={customerAccessToken}
|
162
|
+
data={data}
|
163
|
+
languageCode={languageIsoCode}
|
164
|
+
numCartLines={numCartLines}
|
165
|
+
onAttributesUpdate={adapted.onAttributesUpdate}
|
166
|
+
onAttributesUpdateComplete={adapted.onAttributesUpdateComplete}
|
167
|
+
onBuyerIdentityUpdate={adapted.onBuyerIdentityUpdate}
|
168
|
+
onBuyerIdentityUpdateComplete={
|
169
|
+
adapted.onBuyerIdentityUpdateComplete
|
170
|
+
}
|
171
|
+
onCreate={adapted.onCreate}
|
172
|
+
onCreateComplete={adapted.onCreateComplete}
|
173
|
+
onDiscountCodesUpdate={adapted.onDiscountCodesUpdate}
|
174
|
+
onDiscountCodesUpdateComplete={
|
175
|
+
adapted.onDiscountCodesUpdateComplete
|
176
|
+
}
|
177
|
+
onLineAdd={adapted.onLineAdd}
|
178
|
+
onLineAddComplete={adapted.onLineAddComplete}
|
179
|
+
onLineRemove={adapted.onLineRemove}
|
180
|
+
onLineRemoveComplete={adapted.onLineRemoveComplete}
|
181
|
+
onLineUpdate={adapted.onLineUpdate}
|
182
|
+
onLineUpdateComplete={adapted.onLineUpdateComplete}
|
183
|
+
onNoteUpdate={adapted.onNoteUpdate}
|
184
|
+
onNoteUpdateComplete={adapted.onNoteUpdateComplete}
|
185
|
+
>
|
186
|
+
<RebuyHydrogenReactContext>
|
187
|
+
{children}
|
188
|
+
</RebuyHydrogenReactContext>
|
189
|
+
</CartProvider>
|
190
|
+
</ShopifyProvider>
|
191
|
+
);
|
192
|
+
};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { PartialDeep } from 'type-fest';
|
2
|
+
|
3
|
+
import type { CartReturn } from '@shopify/hydrogen';
|
4
|
+
import type {
|
5
|
+
Attribute,
|
6
|
+
Cart,
|
7
|
+
CartLine,
|
8
|
+
ComponentizableCartLine,
|
9
|
+
CountryCode,
|
10
|
+
LanguageCode,
|
11
|
+
Maybe,
|
12
|
+
} from '@shopify/hydrogen-react/storefront-api-types';
|
13
|
+
|
14
|
+
export type RebuyHydrogenContextProviderProps = {
|
15
|
+
cart: CartReturn;
|
16
|
+
children: React.ReactNode;
|
17
|
+
};
|
18
|
+
|
19
|
+
export type RebuyHydrogenProps = {
|
20
|
+
cartAttributes?: Attribute[];
|
21
|
+
cartCost?: string;
|
22
|
+
cartId?: string;
|
23
|
+
cartLines?: (CartLine | ComponentizableCartLine)[];
|
24
|
+
cartNote?: Maybe<string>;
|
25
|
+
cartQuantity?: number;
|
26
|
+
children: React.ReactNode;
|
27
|
+
};
|
28
|
+
|
29
|
+
export type RebuyHydrogenReactProps = {
|
30
|
+
children: React.ReactNode;
|
31
|
+
};
|
32
|
+
|
33
|
+
export type RebuyHydrogenReactContextProviderProps = {
|
34
|
+
cartFragment?: string;
|
35
|
+
children: React.ReactNode;
|
36
|
+
countryIsoCode?: CountryCode;
|
37
|
+
customerAccessToken?: string;
|
38
|
+
data?: PartialDeep<Cart, { recurseIntoArrays: true }>;
|
39
|
+
languageIsoCode?: LanguageCode;
|
40
|
+
numCartLines?: number;
|
41
|
+
onAttributesUpdate?: () => void;
|
42
|
+
onAttributesUpdateComplete?: () => void;
|
43
|
+
onBuyerIdentityUpdate?: () => void;
|
44
|
+
onBuyerIdentityUpdateComplete?: () => void;
|
45
|
+
onCreate?: () => void;
|
46
|
+
onCreateComplete?: () => void;
|
47
|
+
onDiscountCodesUpdate?: () => void;
|
48
|
+
onDiscountCodesUpdateComplete?: () => void;
|
49
|
+
onLineAdd?: () => void;
|
50
|
+
onLineAddComplete?: () => void;
|
51
|
+
onLineRemove?: () => void;
|
52
|
+
onLineRemoveComplete?: () => void;
|
53
|
+
onLineUpdate?: () => void;
|
54
|
+
onLineUpdateComplete?: () => void;
|
55
|
+
onNoteUpdate?: () => void;
|
56
|
+
onNoteUpdateComplete?: () => void;
|
57
|
+
storefrontApiVersion?: string;
|
58
|
+
};
|
@@ -0,0 +1,467 @@
|
|
1
|
+
export const OPTION_FRAGMENT = `#graphql
|
2
|
+
fragment OptionFragment on ProductOption {
|
3
|
+
id
|
4
|
+
name
|
5
|
+
optionValues {
|
6
|
+
id
|
7
|
+
name
|
8
|
+
swatch {
|
9
|
+
color
|
10
|
+
image {
|
11
|
+
mediaContentType
|
12
|
+
previewImage {
|
13
|
+
height
|
14
|
+
id
|
15
|
+
url
|
16
|
+
width
|
17
|
+
altText
|
18
|
+
}
|
19
|
+
id
|
20
|
+
alt
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
`;
|
26
|
+
/*
|
27
|
+
* STOREFRONT API QUERIES -----------------------------------------------------
|
28
|
+
*/
|
29
|
+
|
30
|
+
// Docs: https://shopify.dev/docs/api/storefront/latest/objects/Cart
|
31
|
+
|
32
|
+
export const CART_LINE_FRAGMENT = `#graphql
|
33
|
+
fragment CartLineFragment on CartLine {
|
34
|
+
id
|
35
|
+
quantity
|
36
|
+
cost {
|
37
|
+
amountPerQuantity {
|
38
|
+
amount
|
39
|
+
currencyCode
|
40
|
+
}
|
41
|
+
compareAtAmountPerQuantity {
|
42
|
+
amount
|
43
|
+
currencyCode
|
44
|
+
}
|
45
|
+
totalAmount {
|
46
|
+
amount
|
47
|
+
currencyCode
|
48
|
+
}
|
49
|
+
subtotalAmount {
|
50
|
+
amount
|
51
|
+
currencyCode
|
52
|
+
}
|
53
|
+
}
|
54
|
+
attributes {
|
55
|
+
key
|
56
|
+
value
|
57
|
+
}
|
58
|
+
discountAllocations {
|
59
|
+
discountedAmount {
|
60
|
+
amount
|
61
|
+
currencyCode
|
62
|
+
}
|
63
|
+
... on CartAutomaticDiscountAllocation {
|
64
|
+
__typename
|
65
|
+
discountedAmount {
|
66
|
+
amount
|
67
|
+
currencyCode
|
68
|
+
}
|
69
|
+
title
|
70
|
+
}
|
71
|
+
... on CartCodeDiscountAllocation {
|
72
|
+
__typename
|
73
|
+
code
|
74
|
+
discountedAmount {
|
75
|
+
amount
|
76
|
+
currencyCode
|
77
|
+
}
|
78
|
+
}
|
79
|
+
... on CartCustomDiscountAllocation {
|
80
|
+
__typename
|
81
|
+
discountedAmount {
|
82
|
+
amount
|
83
|
+
currencyCode
|
84
|
+
}
|
85
|
+
title
|
86
|
+
}
|
87
|
+
}
|
88
|
+
merchandise {
|
89
|
+
... on ProductVariant {
|
90
|
+
availableForSale
|
91
|
+
id
|
92
|
+
sku
|
93
|
+
title
|
94
|
+
compareAtPrice {
|
95
|
+
amount
|
96
|
+
currencyCode
|
97
|
+
}
|
98
|
+
image {
|
99
|
+
altText
|
100
|
+
height
|
101
|
+
id
|
102
|
+
url
|
103
|
+
width
|
104
|
+
}
|
105
|
+
price {
|
106
|
+
amount
|
107
|
+
currencyCode
|
108
|
+
}
|
109
|
+
product {
|
110
|
+
handle
|
111
|
+
id
|
112
|
+
productType
|
113
|
+
tags
|
114
|
+
title
|
115
|
+
vendor
|
116
|
+
collections(first: 10) {
|
117
|
+
nodes {
|
118
|
+
handle
|
119
|
+
}
|
120
|
+
}
|
121
|
+
options {
|
122
|
+
...OptionFragment
|
123
|
+
}
|
124
|
+
images(first: 20) {
|
125
|
+
nodes {
|
126
|
+
altText
|
127
|
+
height
|
128
|
+
id
|
129
|
+
url
|
130
|
+
width
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
selectedOptions {
|
135
|
+
name
|
136
|
+
value
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
` as const;
|
142
|
+
|
143
|
+
export const CART_LINE_COMPONENT_FRAGMENT = `#graphql
|
144
|
+
fragment CartLineComponentFragment on ComponentizableCartLine {
|
145
|
+
id
|
146
|
+
quantity
|
147
|
+
cost {
|
148
|
+
amountPerQuantity {
|
149
|
+
amount
|
150
|
+
currencyCode
|
151
|
+
}
|
152
|
+
compareAtAmountPerQuantity {
|
153
|
+
amount
|
154
|
+
currencyCode
|
155
|
+
}
|
156
|
+
totalAmount {
|
157
|
+
amount
|
158
|
+
currencyCode
|
159
|
+
}
|
160
|
+
subtotalAmount {
|
161
|
+
amount
|
162
|
+
currencyCode
|
163
|
+
}
|
164
|
+
}
|
165
|
+
attributes {
|
166
|
+
key
|
167
|
+
value
|
168
|
+
}
|
169
|
+
discountAllocations {
|
170
|
+
discountedAmount {
|
171
|
+
amount
|
172
|
+
currencyCode
|
173
|
+
}
|
174
|
+
... on CartAutomaticDiscountAllocation {
|
175
|
+
__typename
|
176
|
+
discountedAmount {
|
177
|
+
amount
|
178
|
+
currencyCode
|
179
|
+
}
|
180
|
+
title
|
181
|
+
}
|
182
|
+
... on CartCodeDiscountAllocation {
|
183
|
+
__typename
|
184
|
+
code
|
185
|
+
discountedAmount {
|
186
|
+
amount
|
187
|
+
currencyCode
|
188
|
+
}
|
189
|
+
}
|
190
|
+
... on CartCustomDiscountAllocation {
|
191
|
+
__typename
|
192
|
+
discountedAmount {
|
193
|
+
amount
|
194
|
+
currencyCode
|
195
|
+
}
|
196
|
+
title
|
197
|
+
}
|
198
|
+
}
|
199
|
+
merchandise {
|
200
|
+
... on ProductVariant {
|
201
|
+
availableForSale
|
202
|
+
id
|
203
|
+
sku
|
204
|
+
title
|
205
|
+
compareAtPrice {
|
206
|
+
amount
|
207
|
+
currencyCode
|
208
|
+
}
|
209
|
+
image {
|
210
|
+
altText
|
211
|
+
height
|
212
|
+
id
|
213
|
+
url
|
214
|
+
width
|
215
|
+
}
|
216
|
+
price {
|
217
|
+
amount
|
218
|
+
currencyCode
|
219
|
+
}
|
220
|
+
product {
|
221
|
+
handle
|
222
|
+
id
|
223
|
+
productType
|
224
|
+
tags
|
225
|
+
title
|
226
|
+
vendor
|
227
|
+
collections(first: 10) {
|
228
|
+
nodes {
|
229
|
+
handle
|
230
|
+
}
|
231
|
+
}
|
232
|
+
options {
|
233
|
+
id
|
234
|
+
name
|
235
|
+
optionValues {
|
236
|
+
id
|
237
|
+
name
|
238
|
+
swatch {
|
239
|
+
color
|
240
|
+
image {
|
241
|
+
mediaContentType
|
242
|
+
previewImage {
|
243
|
+
height
|
244
|
+
id
|
245
|
+
url
|
246
|
+
width
|
247
|
+
altText
|
248
|
+
}
|
249
|
+
id
|
250
|
+
alt
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
images(first: 20) {
|
256
|
+
nodes {
|
257
|
+
altText
|
258
|
+
height
|
259
|
+
id
|
260
|
+
url
|
261
|
+
width
|
262
|
+
}
|
263
|
+
}
|
264
|
+
}
|
265
|
+
selectedOptions {
|
266
|
+
name
|
267
|
+
value
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
lineComponents {
|
272
|
+
id
|
273
|
+
quantity
|
274
|
+
cost {
|
275
|
+
amountPerQuantity {
|
276
|
+
amount
|
277
|
+
currencyCode
|
278
|
+
}
|
279
|
+
compareAtAmountPerQuantity {
|
280
|
+
amount
|
281
|
+
currencyCode
|
282
|
+
}
|
283
|
+
totalAmount {
|
284
|
+
amount
|
285
|
+
currencyCode
|
286
|
+
}
|
287
|
+
subtotalAmount {
|
288
|
+
amount
|
289
|
+
currencyCode
|
290
|
+
}
|
291
|
+
}
|
292
|
+
attributes {
|
293
|
+
key
|
294
|
+
value
|
295
|
+
}
|
296
|
+
discountAllocations {
|
297
|
+
discountedAmount {
|
298
|
+
amount
|
299
|
+
currencyCode
|
300
|
+
}
|
301
|
+
... on CartAutomaticDiscountAllocation {
|
302
|
+
__typename
|
303
|
+
discountedAmount {
|
304
|
+
amount
|
305
|
+
currencyCode
|
306
|
+
}
|
307
|
+
title
|
308
|
+
}
|
309
|
+
... on CartCodeDiscountAllocation {
|
310
|
+
__typename
|
311
|
+
code
|
312
|
+
discountedAmount {
|
313
|
+
amount
|
314
|
+
currencyCode
|
315
|
+
}
|
316
|
+
}
|
317
|
+
... on CartCustomDiscountAllocation {
|
318
|
+
__typename
|
319
|
+
discountedAmount {
|
320
|
+
amount
|
321
|
+
currencyCode
|
322
|
+
}
|
323
|
+
title
|
324
|
+
}
|
325
|
+
}
|
326
|
+
merchandise {
|
327
|
+
... on ProductVariant {
|
328
|
+
availableForSale
|
329
|
+
id
|
330
|
+
sku
|
331
|
+
title
|
332
|
+
compareAtPrice {
|
333
|
+
amount
|
334
|
+
currencyCode
|
335
|
+
}
|
336
|
+
image {
|
337
|
+
altText
|
338
|
+
height
|
339
|
+
id
|
340
|
+
url
|
341
|
+
width
|
342
|
+
}
|
343
|
+
price {
|
344
|
+
amount
|
345
|
+
currencyCode
|
346
|
+
}
|
347
|
+
product {
|
348
|
+
handle
|
349
|
+
id
|
350
|
+
productType
|
351
|
+
tags
|
352
|
+
title
|
353
|
+
vendor
|
354
|
+
collections(first: 10) {
|
355
|
+
nodes {
|
356
|
+
handle
|
357
|
+
}
|
358
|
+
}
|
359
|
+
options {
|
360
|
+
...OptionFragment
|
361
|
+
}
|
362
|
+
images(first: 20) {
|
363
|
+
nodes {
|
364
|
+
altText
|
365
|
+
height
|
366
|
+
id
|
367
|
+
url
|
368
|
+
width
|
369
|
+
}
|
370
|
+
}
|
371
|
+
}
|
372
|
+
selectedOptions {
|
373
|
+
name
|
374
|
+
value
|
375
|
+
}
|
376
|
+
}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
` as const;
|
381
|
+
|
382
|
+
export const CART_FRAGMENT = `#graphql
|
383
|
+
fragment CartFragment on Cart {
|
384
|
+
id
|
385
|
+
checkoutUrl
|
386
|
+
createdAt
|
387
|
+
totalQuantity
|
388
|
+
note
|
389
|
+
updatedAt
|
390
|
+
__typename
|
391
|
+
buyerIdentity {
|
392
|
+
countryCode
|
393
|
+
customer {
|
394
|
+
id
|
395
|
+
email
|
396
|
+
firstName
|
397
|
+
lastName
|
398
|
+
displayName
|
399
|
+
}
|
400
|
+
email
|
401
|
+
phone
|
402
|
+
}
|
403
|
+
attributes {
|
404
|
+
key
|
405
|
+
value
|
406
|
+
}
|
407
|
+
cost {
|
408
|
+
subtotalAmount {
|
409
|
+
amount
|
410
|
+
currencyCode
|
411
|
+
}
|
412
|
+
totalAmount {
|
413
|
+
amount
|
414
|
+
currencyCode
|
415
|
+
}
|
416
|
+
}
|
417
|
+
discountAllocations {
|
418
|
+
discountedAmount {
|
419
|
+
amount
|
420
|
+
currencyCode
|
421
|
+
}
|
422
|
+
... on CartAutomaticDiscountAllocation {
|
423
|
+
__typename
|
424
|
+
discountedAmount {
|
425
|
+
amount
|
426
|
+
currencyCode
|
427
|
+
}
|
428
|
+
title
|
429
|
+
}
|
430
|
+
... on CartCodeDiscountAllocation {
|
431
|
+
__typename
|
432
|
+
code
|
433
|
+
discountedAmount {
|
434
|
+
amount
|
435
|
+
currencyCode
|
436
|
+
}
|
437
|
+
}
|
438
|
+
... on CartCustomDiscountAllocation {
|
439
|
+
__typename
|
440
|
+
discountedAmount {
|
441
|
+
amount
|
442
|
+
currencyCode
|
443
|
+
}
|
444
|
+
title
|
445
|
+
}
|
446
|
+
}
|
447
|
+
discountCodes {
|
448
|
+
applicable
|
449
|
+
code
|
450
|
+
}
|
451
|
+
lines(first: $numCartLines) {
|
452
|
+
edges {
|
453
|
+
node {
|
454
|
+
...CartLineComponentFragment
|
455
|
+
}
|
456
|
+
}
|
457
|
+
edges {
|
458
|
+
node {
|
459
|
+
...CartLineFragment
|
460
|
+
}
|
461
|
+
}
|
462
|
+
}
|
463
|
+
}
|
464
|
+
${CART_LINE_FRAGMENT}
|
465
|
+
${CART_LINE_COMPONENT_FRAGMENT}
|
466
|
+
${OPTION_FRAGMENT}
|
467
|
+
` as const;
|