@personizely/shopify-hydrogen 1.0.0 → 1.0.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/dist/index.cjs +386 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +342 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +342 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +264 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +13 -4
- package/dist/classes/Adapter.d.ts +0 -33
- package/dist/classes/Adapter.d.ts.map +0 -1
- package/dist/classes/Adapter.js +0 -126
- package/dist/classes/Adapter.js.map +0 -1
- package/dist/classes/Cart.d.ts +0 -29
- package/dist/classes/Cart.d.ts.map +0 -1
- package/dist/classes/Cart.js +0 -272
- package/dist/classes/Cart.js.map +0 -1
- package/dist/components/PersonizelyProvider.d.ts +0 -36
- package/dist/components/PersonizelyProvider.d.ts.map +0 -1
- package/dist/components/PersonizelyProvider.js +0 -118
- package/dist/components/PersonizelyProvider.js.map +0 -1
- package/dist/graphql/queries/cart.d.ts +0 -7
- package/dist/graphql/queries/cart.d.ts.map +0 -1
- package/dist/graphql/queries/cart.js +0 -142
- package/dist/graphql/queries/cart.js.map +0 -1
- package/dist/graphql/queries/customer.d.ts +0 -5
- package/dist/graphql/queries/customer.d.ts.map +0 -1
- package/dist/graphql/queries/customer.js +0 -72
- package/dist/graphql/queries/customer.js.map +0 -1
- package/dist/graphql/queries/product.d.ts +0 -5
- package/dist/graphql/queries/product.d.ts.map +0 -1
- package/dist/graphql/queries/product.js +0 -114
- package/dist/graphql/queries/product.js.map +0 -1
- package/dist/hooks/useCartAdd.d.ts +0 -3
- package/dist/hooks/useCartAdd.d.ts.map +0 -1
- package/dist/hooks/useCartAdd.js +0 -18
- package/dist/hooks/useCartAdd.js.map +0 -1
- package/dist/hooks/useCheckout.d.ts +0 -2
- package/dist/hooks/useCheckout.d.ts.map +0 -1
- package/dist/hooks/useCheckout.js +0 -12
- package/dist/hooks/useCheckout.js.map +0 -1
- package/dist/hooks/usePageContext.d.ts +0 -3
- package/dist/hooks/usePageContext.d.ts.map +0 -1
- package/dist/hooks/usePageContext.js +0 -6
- package/dist/hooks/usePageContext.js.map +0 -1
- package/dist/hooks/usePersonizely.d.ts +0 -3
- package/dist/hooks/usePersonizely.d.ts.map +0 -1
- package/dist/hooks/usePersonizely.js +0 -11
- package/dist/hooks/usePersonizely.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -170
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/interfaces.d.ts +0 -35
- package/dist/types/interfaces.d.ts.map +0 -1
- package/dist/types/interfaces.js +0 -2
- package/dist/types/interfaces.js.map +0 -1
- package/dist/utils/cookies.d.ts +0 -4
- package/dist/utils/cookies.d.ts.map +0 -1
- package/dist/utils/cookies.js +0 -33
- package/dist/utils/cookies.js.map +0 -1
- package/dist/utils/id.d.ts +0 -3
- package/dist/utils/id.d.ts.map +0 -1
- package/dist/utils/id.js +0 -7
- package/dist/utils/id.js.map +0 -1
- package/dist/utils/storefront-client.d.ts +0 -15
- package/dist/utils/storefront-client.d.ts.map +0 -1
- package/dist/utils/storefront-client.js +0 -39
- package/dist/utils/storefront-client.js.map +0 -1
package/dist/classes/Cart.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { CartData, ICart } from '../types';
|
|
2
|
-
import type { CartReturn } from '@shopify/hydrogen';
|
|
3
|
-
import { StorefrontClient } from '../utils/storefront-client';
|
|
4
|
-
export declare class Cart implements ICart {
|
|
5
|
-
private storefrontClient;
|
|
6
|
-
private listeners;
|
|
7
|
-
private cart;
|
|
8
|
-
private cartPromise;
|
|
9
|
-
private revalidate?;
|
|
10
|
-
constructor(cartPromise: Promise<CartReturn>, storefrontClient: StorefrontClient, revalidate?: () => void);
|
|
11
|
-
updateCartData(cart: CartReturn): void;
|
|
12
|
-
notifyListeners(): void;
|
|
13
|
-
isSynced(): boolean;
|
|
14
|
-
onChange(callback: (cart: CartData) => void): () => void;
|
|
15
|
-
fetch(force?: boolean): Promise<CartData | null>;
|
|
16
|
-
update(action: string, data: any): Promise<void>;
|
|
17
|
-
buy(_variantId: string, _quantity?: number): Promise<void>;
|
|
18
|
-
get(property?: string): any;
|
|
19
|
-
getToken(): string | null;
|
|
20
|
-
getItemsIds(): string[];
|
|
21
|
-
getCurrency(): string;
|
|
22
|
-
getValue(_currency?: string): number;
|
|
23
|
-
getSize(distinct?: boolean): number;
|
|
24
|
-
fetchCollections(_force?: boolean): Promise<any>;
|
|
25
|
-
applyCoupon(code: string, expiresIn?: number): Promise<void>;
|
|
26
|
-
getCoupon(): string | null;
|
|
27
|
-
private toCartData;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=Cart.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cart.d.ts","sourceRoot":"","sources":["../../src/classes/Cart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAW7D,qBAAa,IAAK,YAAW,KAAK;IAChC,OAAO,CAAC,gBAAgB,CAAkB;IAE1C,OAAO,CAAC,SAAS,CAAsC;IAEvD,OAAO,CAAC,IAAI,CAA0B;IAEtC,OAAO,CAAC,WAAW,CAA4B;IAE/C,OAAO,CAAC,UAAU,CAAC,CAAY;gBAElB,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,CAAC,EAAE,MAAM,IAAI;IAU1G,cAAc,CAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IASvC,eAAe,IAAK,IAAI;IAiBxB,QAAQ,IAAK,OAAO;IAQpB,QAAQ,CAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI;IAgBnD,KAAK,CAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAmBvD,MAAM,CAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAmJjD,GAAG,CAAE,UAAU,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAepE,GAAG,CAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG;IAe5B,QAAQ,IAAK,MAAM,GAAG,IAAI;IAS1B,WAAW,IAAK,MAAM,EAAE;IAWxB,WAAW,IAAK,MAAM;IAUtB,QAAQ,CAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAUrC,OAAO,CAAE,QAAQ,GAAE,OAAe,GAAG,MAAM;IAerC,gBAAgB,CAAE,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAQxD,WAAW,CAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCnE,SAAS,IAAK,MAAM,GAAG,IAAI;IAgB3B,OAAO,CAAC,UAAU;CAiBnB"}
|
package/dist/classes/Cart.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { createCookie, readCookie } from '../utils/cookies';
|
|
2
|
-
import { CART_LINES_ADD, CART_LINES_UPDATE, CART_LINES_REMOVE, CART_DISCOUNT_CODES_UPDATE } from '../graphql/queries/cart';
|
|
3
|
-
import { toGId, toId } from '../utils/id';
|
|
4
|
-
const COUPON_COOKIE_NAME = '_ply_coupon';
|
|
5
|
-
export class Cart {
|
|
6
|
-
constructor(cartPromise, storefrontClient, revalidate) {
|
|
7
|
-
this.listeners = [];
|
|
8
|
-
this.cart = null;
|
|
9
|
-
this.storefrontClient = storefrontClient;
|
|
10
|
-
this.cartPromise = cartPromise;
|
|
11
|
-
this.revalidate = revalidate;
|
|
12
|
-
}
|
|
13
|
-
updateCartData(cart) {
|
|
14
|
-
this.cart = cart;
|
|
15
|
-
this.cartPromise = null;
|
|
16
|
-
}
|
|
17
|
-
notifyListeners() {
|
|
18
|
-
if (!this.cart)
|
|
19
|
-
return;
|
|
20
|
-
this.listeners.forEach((listener) => {
|
|
21
|
-
try {
|
|
22
|
-
if (this.cart) {
|
|
23
|
-
listener(this.toCartData(this.cart));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
console.error('Cart listener error:', error);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
isSynced() {
|
|
32
|
-
return !!this.cart;
|
|
33
|
-
}
|
|
34
|
-
onChange(callback) {
|
|
35
|
-
this.listeners.push(callback);
|
|
36
|
-
return () => {
|
|
37
|
-
const index = this.listeners.indexOf(callback);
|
|
38
|
-
if (index > -1) {
|
|
39
|
-
this.listeners.splice(index, 1);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
async fetch(force = true) {
|
|
44
|
-
if (this.cart && !force) {
|
|
45
|
-
return this.toCartData(this.cart);
|
|
46
|
-
}
|
|
47
|
-
if (this.cartPromise) {
|
|
48
|
-
this.cart = await this.cartPromise;
|
|
49
|
-
return this.toCartData(this.cart);
|
|
50
|
-
}
|
|
51
|
-
if (!this.cart)
|
|
52
|
-
return null;
|
|
53
|
-
return this.toCartData(this.cart);
|
|
54
|
-
}
|
|
55
|
-
async update(action, data) {
|
|
56
|
-
if (!this.cart) {
|
|
57
|
-
throw new Error('Cart not initialized');
|
|
58
|
-
}
|
|
59
|
-
const lineIds = this.cart.lines.nodes.map((line) => line.id);
|
|
60
|
-
try {
|
|
61
|
-
let result;
|
|
62
|
-
switch (action) {
|
|
63
|
-
case 'add':
|
|
64
|
-
result = await this.storefrontClient.mutate(CART_LINES_ADD, {
|
|
65
|
-
cartId: this.cart.id,
|
|
66
|
-
lines: [{
|
|
67
|
-
merchandiseId: toGId(data.id, 'ProductVariant'),
|
|
68
|
-
quantity: data.quantity || 1,
|
|
69
|
-
attributes: data.properties
|
|
70
|
-
? Object.entries(data.properties).map(([key, value]) => ({
|
|
71
|
-
key,
|
|
72
|
-
value: String(value)
|
|
73
|
-
}))
|
|
74
|
-
: undefined
|
|
75
|
-
}]
|
|
76
|
-
});
|
|
77
|
-
if (result?.cartLinesAdd?.cart) {
|
|
78
|
-
this.cart = result.cartLinesAdd.cart;
|
|
79
|
-
this.notifyListeners();
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
case 'update':
|
|
83
|
-
case 'change':
|
|
84
|
-
if (data.updates) {
|
|
85
|
-
const linesToUpdate = [];
|
|
86
|
-
const linesToAdd = [];
|
|
87
|
-
Object.entries(data.updates).forEach(([variantId, quantity]) => {
|
|
88
|
-
const line = this.cart.lines.nodes.find((line) => toId(line.merchandise.id) === Number(variantId));
|
|
89
|
-
if (line) {
|
|
90
|
-
linesToUpdate.push({
|
|
91
|
-
id: line.id,
|
|
92
|
-
quantity: Number(quantity)
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
else if (Number(quantity) > 0) {
|
|
96
|
-
linesToAdd.push({
|
|
97
|
-
merchandiseId: toGId(Number(variantId), 'ProductVariant'),
|
|
98
|
-
quantity: Number(quantity)
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
const mutations = [];
|
|
103
|
-
if (linesToUpdate.length > 0) {
|
|
104
|
-
mutations.push(this.storefrontClient.mutate(CART_LINES_UPDATE, {
|
|
105
|
-
cartId: this.cart.id,
|
|
106
|
-
lines: linesToUpdate
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
if (linesToAdd.length > 0) {
|
|
110
|
-
mutations.push(this.storefrontClient.mutate(CART_LINES_ADD, {
|
|
111
|
-
cartId: this.cart.id,
|
|
112
|
-
lines: linesToAdd
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
if (mutations.length > 0) {
|
|
116
|
-
const results = await Promise.all(mutations);
|
|
117
|
-
const lastResult = results[results.length - 1];
|
|
118
|
-
if (lastResult?.cartLinesUpdate?.cart || lastResult?.cartLinesAdd?.cart) {
|
|
119
|
-
this.cart = lastResult.cartLinesUpdate?.cart || lastResult.cartLinesAdd?.cart;
|
|
120
|
-
this.notifyListeners();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
result = await this.storefrontClient.mutate(CART_LINES_UPDATE, {
|
|
126
|
-
cartId: this.cart.id,
|
|
127
|
-
lines: [{
|
|
128
|
-
id: `gid://shopify/CartLine/${data.id}`,
|
|
129
|
-
quantity: data.quantity
|
|
130
|
-
}]
|
|
131
|
-
});
|
|
132
|
-
if (result?.cartLinesUpdate?.cart) {
|
|
133
|
-
this.cart = result.cartLinesUpdate.cart;
|
|
134
|
-
this.notifyListeners();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (data.discount && this.cart) {
|
|
138
|
-
result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {
|
|
139
|
-
cartId: this.cart.id,
|
|
140
|
-
discountCodes: [data.discount]
|
|
141
|
-
});
|
|
142
|
-
if (result?.cartDiscountCodesUpdate?.cart) {
|
|
143
|
-
this.cart = result.cartDiscountCodesUpdate.cart;
|
|
144
|
-
this.notifyListeners();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
break;
|
|
148
|
-
case 'clear':
|
|
149
|
-
result = await this.storefrontClient.mutate(CART_LINES_REMOVE, {
|
|
150
|
-
cartId: this.cart.id,
|
|
151
|
-
lineIds
|
|
152
|
-
});
|
|
153
|
-
if (result?.cartLinesRemove?.cart) {
|
|
154
|
-
this.cart = result.cartLinesRemove.cart;
|
|
155
|
-
this.notifyListeners();
|
|
156
|
-
}
|
|
157
|
-
break;
|
|
158
|
-
default:
|
|
159
|
-
console.warn(`Unknown cart action: ${action}`);
|
|
160
|
-
}
|
|
161
|
-
if (this.revalidate) {
|
|
162
|
-
this.revalidate();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
console.error('Cart update error:', error);
|
|
167
|
-
throw error;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
async buy(_variantId, _quantity = 1) {
|
|
171
|
-
if (!this.cart)
|
|
172
|
-
return;
|
|
173
|
-
const coupon = this.getCoupon();
|
|
174
|
-
const baseUrl = this.cart.checkoutUrl || '/checkout';
|
|
175
|
-
const url = coupon ? `${baseUrl}?discount=${coupon}` : baseUrl;
|
|
176
|
-
if (typeof window !== 'undefined') {
|
|
177
|
-
window.location.href = url;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
get(property) {
|
|
181
|
-
if (!this.cart) {
|
|
182
|
-
return property ? undefined : null;
|
|
183
|
-
}
|
|
184
|
-
if (!property) {
|
|
185
|
-
return this.toCartData(this.cart);
|
|
186
|
-
}
|
|
187
|
-
return this.toCartData(this.cart)[property];
|
|
188
|
-
}
|
|
189
|
-
getToken() {
|
|
190
|
-
if (!this.cart)
|
|
191
|
-
return null;
|
|
192
|
-
return this.cart.id || null;
|
|
193
|
-
}
|
|
194
|
-
getItemsIds() {
|
|
195
|
-
if (!this.cart) {
|
|
196
|
-
return [];
|
|
197
|
-
}
|
|
198
|
-
return this.cart.lines.nodes.map(line => line.merchandise.product.id);
|
|
199
|
-
}
|
|
200
|
-
getCurrency() {
|
|
201
|
-
if (!this.cart)
|
|
202
|
-
return 'USD';
|
|
203
|
-
return this.cart.cost.totalAmount.currencyCode;
|
|
204
|
-
}
|
|
205
|
-
getValue(_currency) {
|
|
206
|
-
if (!this.cart)
|
|
207
|
-
return 0;
|
|
208
|
-
return parseFloat(this.cart.cost.totalAmount.amount) * 100;
|
|
209
|
-
}
|
|
210
|
-
getSize(distinct = false) {
|
|
211
|
-
if (!this.cart)
|
|
212
|
-
return 0;
|
|
213
|
-
if (distinct) {
|
|
214
|
-
const uniqueProductIds = new Set(this.cart.lines.nodes.map(line => line.merchandise.product.id));
|
|
215
|
-
return uniqueProductIds.size;
|
|
216
|
-
}
|
|
217
|
-
return this.cart.totalQuantity;
|
|
218
|
-
}
|
|
219
|
-
async fetchCollections(_force = false) {
|
|
220
|
-
console.warn('fetchCollections: Not implemented for Hydrogen. Use custom metafield query.');
|
|
221
|
-
return {};
|
|
222
|
-
}
|
|
223
|
-
async applyCoupon(code, expiresIn) {
|
|
224
|
-
if (!this.cart) {
|
|
225
|
-
throw new Error('Cart not initialized');
|
|
226
|
-
}
|
|
227
|
-
createCookie(COUPON_COOKIE_NAME, code, expiresIn);
|
|
228
|
-
try {
|
|
229
|
-
const result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {
|
|
230
|
-
cartId: this.cart.id,
|
|
231
|
-
discountCodes: [code]
|
|
232
|
-
});
|
|
233
|
-
if (result?.cartDiscountCodesUpdate?.cart) {
|
|
234
|
-
this.cart = result.cartDiscountCodesUpdate.cart;
|
|
235
|
-
this.notifyListeners();
|
|
236
|
-
}
|
|
237
|
-
if (this.revalidate) {
|
|
238
|
-
this.revalidate();
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch (error) {
|
|
242
|
-
console.error('Error applying coupon:', error);
|
|
243
|
-
throw error;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
getCoupon() {
|
|
247
|
-
if (!this.cart)
|
|
248
|
-
return null;
|
|
249
|
-
if (this.cart.discountCodes && this.cart.discountCodes.length > 0) {
|
|
250
|
-
return this.cart.discountCodes[0].code;
|
|
251
|
-
}
|
|
252
|
-
return readCookie(COUPON_COOKIE_NAME);
|
|
253
|
-
}
|
|
254
|
-
toCartData(cart) {
|
|
255
|
-
return {
|
|
256
|
-
token: cart.id,
|
|
257
|
-
item_count: cart.totalQuantity || 0,
|
|
258
|
-
items: (cart.lines?.nodes || []).map(line => ({
|
|
259
|
-
id: toId(line.id),
|
|
260
|
-
product_id: toId(line.merchandise.product.id),
|
|
261
|
-
variant_id: toId(line.merchandise.id),
|
|
262
|
-
price: Number(line.merchandise.price.amount) * 100,
|
|
263
|
-
quantity: line.quantity
|
|
264
|
-
})),
|
|
265
|
-
total_price: Number(cart.cost.totalAmount.amount) * 100,
|
|
266
|
-
discount_codes: cart.discountCodes,
|
|
267
|
-
attributes: cart.attributes,
|
|
268
|
-
note: cart.note
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
//# sourceMappingURL=Cart.js.map
|
package/dist/classes/Cart.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cart.js","sourceRoot":"","sources":["../../src/classes/Cart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG3D,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,kBAAkB,GAAG,aAAa,CAAA;AAExC,MAAM,OAAO,IAAI;IAWf,YAAa,WAAgC,EAAE,gBAAkC,EAAE,UAAuB;QARlG,cAAS,GAAoC,EAAE,CAAA;QAE/C,SAAI,GAAsB,IAAI,CAAA;QAOpC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAMD,cAAc,CAAE,IAAgB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QA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AAC,OAAO,CAAC,EAAE,CAAC;gBAC7C,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;gBACrC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG;gBAClD,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC,CAAC;YACH,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,GAAG;YACvD,cAAc,EAAE,IAAI,CAAC,aAAa;YAClC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { PersonizelyConfigMethods, HydrogenConfig, CartAddProduct } from '../types';
|
|
3
|
-
import { Cart } from '../classes/Cart';
|
|
4
|
-
import { Adapter } from '../classes/Adapter';
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
__PLY_HYDROGEN_CONFIG__?: HydrogenConfig;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export type PersonizelyContextType = {
|
|
11
|
-
cart: Cart;
|
|
12
|
-
adapter: Adapter;
|
|
13
|
-
websiteApiKey: string;
|
|
14
|
-
triggerCartAdd: (product: CartAddProduct) => Promise<boolean>;
|
|
15
|
-
triggerCheckout: () => Promise<boolean>;
|
|
16
|
-
};
|
|
17
|
-
export declare const PersonizelyContext: React.Context<PersonizelyContextType | null>;
|
|
18
|
-
export type PersonizelyProviderProps = {
|
|
19
|
-
websiteApiKey: string;
|
|
20
|
-
storefrontAccessToken: string;
|
|
21
|
-
shopDomain: string;
|
|
22
|
-
apiVersion?: string;
|
|
23
|
-
scriptBaseUrl?: string;
|
|
24
|
-
locale?: string;
|
|
25
|
-
currency?: {
|
|
26
|
-
rate: number;
|
|
27
|
-
active: string;
|
|
28
|
-
base: string;
|
|
29
|
-
};
|
|
30
|
-
market?: string;
|
|
31
|
-
methods?: PersonizelyConfigMethods;
|
|
32
|
-
children: ReactNode;
|
|
33
|
-
customerAccessToken?: string | null;
|
|
34
|
-
};
|
|
35
|
-
export declare function PersonizelyProvider({ websiteApiKey, storefrontAccessToken, shopDomain, locale, currency, market, apiVersion, scriptBaseUrl, methods, children, customerAccessToken }: PersonizelyProviderProps): React.JSX.Element;
|
|
36
|
-
//# sourceMappingURL=PersonizelyProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PersonizelyProvider.d.ts","sourceRoot":"","sources":["../../src/components/PersonizelyProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6C,SAAS,EAAE,MAAM,OAAO,CAAA;AAEnF,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,cAAc,EACf,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAG5C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,uBAAuB,CAAC,EAAE,cAAc,CAAA;KACzC;CACF;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7D,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CACxC,CAAA;AAED,eAAO,MAAM,kBAAkB,8CAAqD,CAAA;AAEpF,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,MAAM,CAAA;IACrB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,wBAAwB,CAAA;IAClC,QAAQ,EAAE,SAAS,CAAA;IAInB,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC,CAAA;AAED,wBAAgB,mBAAmB,CAAE,EACnC,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,MAAM,EACN,QAAQ,EACR,MAAM,EACN,UAAU,EACV,aAAa,EACb,OAAO,EACP,QAAQ,EACR,mBAAmB,EACpB,EAAE,wBAAwB,qBAiI1B"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
import { useMatches, useRevalidator } from 'react-router';
|
|
3
|
-
import { Cart } from '../classes/Cart';
|
|
4
|
-
import { Adapter } from '../classes/Adapter';
|
|
5
|
-
import { StorefrontClient } from '../utils/storefront-client';
|
|
6
|
-
export const PersonizelyContext = createContext(null);
|
|
7
|
-
export function PersonizelyProvider({ websiteApiKey, storefrontAccessToken, shopDomain, locale, currency, market, apiVersion, scriptBaseUrl, methods, children, customerAccessToken }) {
|
|
8
|
-
const matches = useMatches();
|
|
9
|
-
const rootMatch = matches.find(m => m.id === 'root');
|
|
10
|
-
const localCart = rootMatch?.loaderData?.cart;
|
|
11
|
-
const revalidator = useRevalidator();
|
|
12
|
-
const storefrontClient = useMemo(() => {
|
|
13
|
-
return new StorefrontClient({
|
|
14
|
-
storefrontAccessToken,
|
|
15
|
-
shopDomain,
|
|
16
|
-
apiVersion
|
|
17
|
-
});
|
|
18
|
-
}, [storefrontAccessToken, shopDomain, apiVersion]);
|
|
19
|
-
const adapter = useMemo(() => {
|
|
20
|
-
const adapterInstance = new Adapter({
|
|
21
|
-
locale,
|
|
22
|
-
currency,
|
|
23
|
-
market,
|
|
24
|
-
methods
|
|
25
|
-
}, storefrontClient);
|
|
26
|
-
if (customerAccessToken) {
|
|
27
|
-
adapterInstance.setCustomerAccessToken(customerAccessToken);
|
|
28
|
-
}
|
|
29
|
-
return adapterInstance;
|
|
30
|
-
}, []);
|
|
31
|
-
const cart = useMemo(() => new Cart(localCart, storefrontClient, revalidator.revalidate), []);
|
|
32
|
-
const prevCartDataRef = useRef(null);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
localCart.then((data) => {
|
|
35
|
-
if (data && data !== prevCartDataRef.current) {
|
|
36
|
-
cart.updateCartData(data);
|
|
37
|
-
cart.notifyListeners();
|
|
38
|
-
prevCartDataRef.current = data;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}, [localCart, cart]);
|
|
42
|
-
const cartAddCallbacksRef = useRef([]);
|
|
43
|
-
const checkoutCallbacksRef = useRef([]);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (typeof window === 'undefined') {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
window.__PLY_HYDROGEN_CONFIG__ = {
|
|
49
|
-
cart,
|
|
50
|
-
adapter,
|
|
51
|
-
onCartAdd: (callback) => {
|
|
52
|
-
cartAddCallbacksRef.current.push(callback);
|
|
53
|
-
return () => {
|
|
54
|
-
const index = cartAddCallbacksRef.current.indexOf(callback);
|
|
55
|
-
if (index > -1) {
|
|
56
|
-
cartAddCallbacksRef.current.splice(index, 1);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
onCheckout: (callback) => {
|
|
61
|
-
checkoutCallbacksRef.current.push(callback);
|
|
62
|
-
return () => {
|
|
63
|
-
const index = checkoutCallbacksRef.current.indexOf(callback);
|
|
64
|
-
if (index > -1) {
|
|
65
|
-
checkoutCallbacksRef.current.splice(index, 1);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const script = document.createElement('script');
|
|
71
|
-
const baseUrl = scriptBaseUrl || 'https://static.personizely.net';
|
|
72
|
-
script.src = `${baseUrl}/${websiteApiKey}.js`;
|
|
73
|
-
document.head.appendChild(script);
|
|
74
|
-
return () => {
|
|
75
|
-
delete window.__PLY_HYDROGEN_CONFIG__;
|
|
76
|
-
if (script) {
|
|
77
|
-
script.remove();
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}, []);
|
|
81
|
-
const contextValue = useMemo(() => ({
|
|
82
|
-
cart,
|
|
83
|
-
adapter,
|
|
84
|
-
websiteApiKey,
|
|
85
|
-
triggerCartAdd: async (product) => {
|
|
86
|
-
let shown = false;
|
|
87
|
-
for (const callback of cartAddCallbacksRef.current) {
|
|
88
|
-
try {
|
|
89
|
-
const result = await callback(product);
|
|
90
|
-
if (result) {
|
|
91
|
-
shown = true;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
console.error('Cart add callback error:', error);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return shown;
|
|
99
|
-
},
|
|
100
|
-
triggerCheckout: async () => {
|
|
101
|
-
let shown = false;
|
|
102
|
-
for (const callback of checkoutCallbacksRef.current) {
|
|
103
|
-
try {
|
|
104
|
-
const result = await callback();
|
|
105
|
-
if (result) {
|
|
106
|
-
shown = true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
console.error('Checkout callback error:', error);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return shown;
|
|
114
|
-
}
|
|
115
|
-
}), [cart, adapter, websiteApiKey]);
|
|
116
|
-
return (React.createElement(PersonizelyContext.Provider, { value: contextValue }, children));
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=PersonizelyProvider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E;YAClE,IAAI,KAAK,GAAG,KAAK,CAAA;YACjB,KAAK,MAAM,QAAQ,IAAI,mBAAmB,CAAC,OAAO,EAAE,CAAC;gBACnD,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAA;oBACtC,IAAI,MAAM,EAAE,CAAC;wBACX,KAAK,GAAG,IAAI,CAAA;oBACd,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;gBAClD,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,eAAe,EAAE,KAAK,IAAsB,EAAE;YAC5C,IAAI,KAAK,GAAG,KAAK,CAAA;YACjB,KAAK,MAAM,QAAQ,IAAI,oBAAoB,CAAC,OAAO,EAAE,CAAC;gBACpD,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAA;oBAC/B,IAAI,MAAM,EAAE,CAAC;wBACX,KAAK,GAAG,IAAI,CAAA;oBACd,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;gBAClD,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAA;IAEnC,OAAO,CACL,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAC7C,QAAQ,CACmB,CAC/B,CAAA;AACH,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const CART_FRAGMENT = "\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n";
|
|
2
|
-
export declare const GET_CART = "\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...CartFragment\n }\n }\n \n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n\n";
|
|
3
|
-
export declare const CART_LINES_ADD = "\n mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n \n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n\n";
|
|
4
|
-
export declare const CART_LINES_UPDATE = "\n mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n \n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n\n";
|
|
5
|
-
export declare const CART_LINES_REMOVE = "\n mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n \n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n\n";
|
|
6
|
-
export declare const CART_DISCOUNT_CODES_UPDATE = "\n mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n \n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n\n";
|
|
7
|
-
//# sourceMappingURL=cart.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/cart.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,g1CA4EzB,CAAA;AAED,eAAO,MAAM,QAAQ,m7CAOpB,CAAA;AAMD,eAAO,MAAM,cAAc,ukDAa1B,CAAA;AAED,eAAO,MAAM,iBAAiB,mlDAa7B,CAAA;AAED,eAAO,MAAM,iBAAiB,wkDAa7B,CAAA;AAED,eAAO,MAAM,0BAA0B,8mDAatC,CAAA"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
export const CART_FRAGMENT = `
|
|
2
|
-
fragment CartFragment on Cart {
|
|
3
|
-
id
|
|
4
|
-
checkoutUrl
|
|
5
|
-
totalQuantity
|
|
6
|
-
cost {
|
|
7
|
-
subtotalAmount {
|
|
8
|
-
amount
|
|
9
|
-
currencyCode
|
|
10
|
-
}
|
|
11
|
-
totalAmount {
|
|
12
|
-
amount
|
|
13
|
-
currencyCode
|
|
14
|
-
}
|
|
15
|
-
totalTaxAmount {
|
|
16
|
-
amount
|
|
17
|
-
currencyCode
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
lines(first: 100) {
|
|
21
|
-
nodes {
|
|
22
|
-
id
|
|
23
|
-
quantity
|
|
24
|
-
cost {
|
|
25
|
-
totalAmount {
|
|
26
|
-
amount
|
|
27
|
-
currencyCode
|
|
28
|
-
}
|
|
29
|
-
amountPerQuantity {
|
|
30
|
-
amount
|
|
31
|
-
currencyCode
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
merchandise {
|
|
35
|
-
... on ProductVariant {
|
|
36
|
-
id
|
|
37
|
-
title
|
|
38
|
-
price {
|
|
39
|
-
amount
|
|
40
|
-
currencyCode
|
|
41
|
-
}
|
|
42
|
-
image {
|
|
43
|
-
url
|
|
44
|
-
altText
|
|
45
|
-
}
|
|
46
|
-
selectedOptions {
|
|
47
|
-
name
|
|
48
|
-
value
|
|
49
|
-
}
|
|
50
|
-
product {
|
|
51
|
-
id
|
|
52
|
-
handle
|
|
53
|
-
title
|
|
54
|
-
featuredImage {
|
|
55
|
-
url
|
|
56
|
-
altText
|
|
57
|
-
}
|
|
58
|
-
tags
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
attributes {
|
|
63
|
-
key
|
|
64
|
-
value
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
discountCodes {
|
|
69
|
-
code
|
|
70
|
-
applicable
|
|
71
|
-
}
|
|
72
|
-
attributes {
|
|
73
|
-
key
|
|
74
|
-
value
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
`;
|
|
78
|
-
export const GET_CART = `
|
|
79
|
-
query getCart($cartId: ID!) {
|
|
80
|
-
cart(id: $cartId) {
|
|
81
|
-
...CartFragment
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
${CART_FRAGMENT}
|
|
85
|
-
`;
|
|
86
|
-
export const CART_LINES_ADD = `
|
|
87
|
-
mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {
|
|
88
|
-
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
89
|
-
cart {
|
|
90
|
-
...CartFragment
|
|
91
|
-
}
|
|
92
|
-
userErrors {
|
|
93
|
-
field
|
|
94
|
-
message
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
${CART_FRAGMENT}
|
|
99
|
-
`;
|
|
100
|
-
export const CART_LINES_UPDATE = `
|
|
101
|
-
mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
|
|
102
|
-
cartLinesUpdate(cartId: $cartId, lines: $lines) {
|
|
103
|
-
cart {
|
|
104
|
-
...CartFragment
|
|
105
|
-
}
|
|
106
|
-
userErrors {
|
|
107
|
-
field
|
|
108
|
-
message
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
${CART_FRAGMENT}
|
|
113
|
-
`;
|
|
114
|
-
export const CART_LINES_REMOVE = `
|
|
115
|
-
mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {
|
|
116
|
-
cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
|
|
117
|
-
cart {
|
|
118
|
-
...CartFragment
|
|
119
|
-
}
|
|
120
|
-
userErrors {
|
|
121
|
-
field
|
|
122
|
-
message
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
${CART_FRAGMENT}
|
|
127
|
-
`;
|
|
128
|
-
export const CART_DISCOUNT_CODES_UPDATE = `
|
|
129
|
-
mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {
|
|
130
|
-
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
131
|
-
cart {
|
|
132
|
-
...CartFragment
|
|
133
|
-
}
|
|
134
|
-
userErrors {
|
|
135
|
-
field
|
|
136
|
-
message
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
${CART_FRAGMENT}
|
|
141
|
-
`;
|
|
142
|
-
//# sourceMappingURL=cart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cart.js","sourceRoot":"","sources":["../../../src/graphql/queries/cart.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4E5B,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;IAMpB,aAAa;CAChB,CAAA;AAMD,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;IAY1B,aAAa;CAChB,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;IAY7B,aAAa;CAChB,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;IAY7B,aAAa;CAChB,CAAA;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;;;;IAYtC,aAAa;CAChB,CAAA"}
|