@daffodil/cart 0.94.1 → 0.95.0
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/fesm2022/daffodil-cart-driver-in-memory.mjs +1618 -1198
- package/fesm2022/daffodil-cart-driver-in-memory.mjs.map +1 -1
- package/fesm2022/daffodil-cart-driver-magento-2.4.7-testing.mjs +546 -0
- package/fesm2022/daffodil-cart-driver-magento-2.4.7-testing.mjs.map +1 -0
- package/fesm2022/daffodil-cart-driver-magento-2.4.7.mjs +2607 -0
- package/fesm2022/daffodil-cart-driver-magento-2.4.7.mjs.map +1 -0
- package/fesm2022/daffodil-cart-driver-magento-auto-testing.mjs +7 -0
- package/fesm2022/daffodil-cart-driver-magento-auto-testing.mjs.map +1 -0
- package/fesm2022/daffodil-cart-driver-magento-auto.mjs +7 -0
- package/fesm2022/daffodil-cart-driver-magento-auto.mjs.map +1 -0
- package/fesm2022/daffodil-cart-driver-testing.mjs +553 -335
- package/fesm2022/daffodil-cart-driver-testing.mjs.map +1 -1
- package/fesm2022/daffodil-cart-driver.mjs +167 -292
- package/fesm2022/daffodil-cart-driver.mjs.map +1 -1
- package/fesm2022/daffodil-cart-routing.mjs +741 -542
- package/fesm2022/daffodil-cart-routing.mjs.map +1 -1
- package/fesm2022/daffodil-cart-state-testing.mjs +288 -193
- package/fesm2022/daffodil-cart-state-testing.mjs.map +1 -1
- package/fesm2022/daffodil-cart-state.mjs +2571 -2800
- package/fesm2022/daffodil-cart-state.mjs.map +1 -1
- package/fesm2022/daffodil-cart-testing.mjs +542 -357
- package/fesm2022/daffodil-cart-testing.mjs.map +1 -1
- package/fesm2022/daffodil-cart.mjs +131 -200
- package/fesm2022/daffodil-cart.mjs.map +1 -1
- package/package.json +1 -1
- package/types/daffodil-cart-driver-in-memory.d.ts +273 -292
- package/types/daffodil-cart-driver-magento-2.4.7-testing.d.ts +176 -0
- package/types/daffodil-cart-driver-magento-2.4.7.d.ts +860 -0
- package/types/daffodil-cart-driver-magento-auto-testing.d.ts +1 -0
- package/types/daffodil-cart-driver-magento-auto.d.ts +1 -0
- package/types/daffodil-cart-driver-testing.d.ts +111 -118
- package/types/daffodil-cart-driver.d.ts +219 -262
- package/types/daffodil-cart-routing.d.ts +130 -149
- package/types/daffodil-cart-state-testing.d.ts +115 -114
- package/types/daffodil-cart-state.d.ts +1126 -1173
- package/types/daffodil-cart-testing.d.ts +146 -158
- package/types/daffodil-cart.d.ts +302 -321
- package/fesm2022/daffodil-cart-driver-magento-testing.mjs +0 -332
- package/fesm2022/daffodil-cart-driver-magento-testing.mjs.map +0 -1
- package/fesm2022/daffodil-cart-driver-magento.mjs +0 -2273
- package/fesm2022/daffodil-cart-driver-magento.mjs.map +0 -1
- package/types/daffodil-cart-driver-magento-testing.d.ts +0 -188
- package/types/daffodil-cart-driver-magento.d.ts +0 -999
|
@@ -1,2273 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Inject, inject, NgModule } from '@angular/core';
|
|
3
|
-
import { DaffCartItemInputType, DaffCartTotalTypeEnum } from '@daffodil/cart';
|
|
4
|
-
import { MagentoProductStockStatusEnum } from '@daffodil/product/driver/magento';
|
|
5
|
-
import { daffAdd, createMultiInjectionToken, createSingleInjectionToken } from '@daffodil/core';
|
|
6
|
-
import * as i1 from 'apollo-angular';
|
|
7
|
-
import { gql, Apollo } from 'apollo-angular';
|
|
8
|
-
import { magentoMoneyFragment, daffMagentoTransformGraphQlError, daffTransformMagentoError } from '@daffodil/driver/magento';
|
|
9
|
-
import * as i5 from '@daffodil/core/graphql';
|
|
10
|
-
import { daffBuildFragmentNameSpread, daffBuildFragmentDefinition, DaffQueuedApollo } from '@daffodil/core/graphql';
|
|
11
|
-
import { CombinedGraphQLErrors } from '@apollo/client';
|
|
12
|
-
import { DaffUnauthorizedForCartError, DaffCartNotFoundError, DaffCartDriverErrorCodes, DaffCartInvalidAPIResponseError, DaffProductOutOfStockError, DaffProductInsufficientStockError, DaffCartDriverErrorMap, DaffInvalidCouponCodeError, DaffCartItemDriver, provideDaffCartDriver, provideDaffCartItemDriver, provideDaffCartAddressDriver, provideDaffCartBillingAddressDriver, provideDaffCartShippingAddressDriver, provideDaffCartShippingMethodsDriver, provideDaffCartShippingInformationDriver, provideDaffCartPaymentDriver, provideDaffCartPaymentMethodsDriver, provideDaffCartOrderDriver, provideDaffCartCouponDriver, daffCartDriverProvideFreePaymentMethod } from '@daffodil/cart/driver';
|
|
13
|
-
import { DaffBadInputError } from '@daffodil/driver';
|
|
14
|
-
import { DaffProductNotFoundError } from '@daffodil/product/driver';
|
|
15
|
-
import { of, throwError, forkJoin } from 'rxjs';
|
|
16
|
-
import { map, switchMap, catchError } from 'rxjs/operators';
|
|
17
|
-
import { CommonModule } from '@angular/common';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Transforms magento addresses into an object usable by daffodil.
|
|
21
|
-
*/
|
|
22
|
-
class DaffMagentoCartAddressTransformer {
|
|
23
|
-
/**
|
|
24
|
-
* Transforms the magento MagentoCart from the magento cart query into a DaffCartAddress.
|
|
25
|
-
*
|
|
26
|
-
* @param address the address from a magento cart query.
|
|
27
|
-
*/
|
|
28
|
-
transform(address) {
|
|
29
|
-
return address ? {
|
|
30
|
-
// address
|
|
31
|
-
street: address.street[0],
|
|
32
|
-
street2: address.street[1],
|
|
33
|
-
city: address.city,
|
|
34
|
-
region: String(address.region.region_id),
|
|
35
|
-
region_code: address.region.code,
|
|
36
|
-
country: address.country.label,
|
|
37
|
-
country_id: address.country.code,
|
|
38
|
-
postcode: address.postcode,
|
|
39
|
-
// personal address
|
|
40
|
-
firstname: address.firstname,
|
|
41
|
-
lastname: address.lastname,
|
|
42
|
-
telephone: address.telephone,
|
|
43
|
-
email: address.email,
|
|
44
|
-
id: address.customer_address_id ? String(address.customer_address_id) : null,
|
|
45
|
-
// TODO: implement
|
|
46
|
-
suffix: null,
|
|
47
|
-
middlename: null,
|
|
48
|
-
prefix: null,
|
|
49
|
-
} : null;
|
|
50
|
-
}
|
|
51
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressTransformer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
52
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressTransformer, providedIn: 'root' }); }
|
|
53
|
-
}
|
|
54
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressTransformer, decorators: [{
|
|
55
|
-
type: Injectable,
|
|
56
|
-
args: [{
|
|
57
|
-
providedIn: 'root',
|
|
58
|
-
}]
|
|
59
|
-
}] });
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Transforms magento addresses into an object usable by daffodil.
|
|
63
|
-
*/
|
|
64
|
-
class DaffMagentoBillingAddressTransformer {
|
|
65
|
-
constructor(addressTransformer) {
|
|
66
|
-
this.addressTransformer = addressTransformer;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Transforms the magento MagentoCart from the magento cart query into a DaffCartAddress.
|
|
70
|
-
*
|
|
71
|
-
* @param address the address from a magento cart query.
|
|
72
|
-
*/
|
|
73
|
-
transform(address) {
|
|
74
|
-
return address
|
|
75
|
-
? this.addressTransformer.transform(address)
|
|
76
|
-
: null;
|
|
77
|
-
}
|
|
78
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoBillingAddressTransformer, deps: [{ token: DaffMagentoCartAddressTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
79
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoBillingAddressTransformer, providedIn: 'root' }); }
|
|
80
|
-
}
|
|
81
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoBillingAddressTransformer, decorators: [{
|
|
82
|
-
type: Injectable,
|
|
83
|
-
args: [{
|
|
84
|
-
providedIn: 'root',
|
|
85
|
-
}]
|
|
86
|
-
}], ctorParameters: () => [{ type: DaffMagentoCartAddressTransformer }] });
|
|
87
|
-
|
|
88
|
-
function daffMagentoCouponTransform(coupon) {
|
|
89
|
-
return {
|
|
90
|
-
id: coupon.code,
|
|
91
|
-
code: coupon.code,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Transforms the magento MagentoCartItem from the magento cart query into a DaffCartItem.
|
|
97
|
-
*
|
|
98
|
-
* @param response the response from a magento cart query.
|
|
99
|
-
*/
|
|
100
|
-
function transformMagentoSimpleCartItem(cartItem) {
|
|
101
|
-
return {
|
|
102
|
-
// base
|
|
103
|
-
type: DaffCartItemInputType.Simple,
|
|
104
|
-
id: cartItem.id,
|
|
105
|
-
url: `/${cartItem.product.url_key}${cartItem.product.url_suffix}`,
|
|
106
|
-
sku: cartItem.product.sku,
|
|
107
|
-
name: cartItem.product.name,
|
|
108
|
-
qty: cartItem.quantity,
|
|
109
|
-
price: cartItem.prices.price.value,
|
|
110
|
-
row_total: cartItem.prices.row_total.value,
|
|
111
|
-
product_id: String(cartItem.product.id),
|
|
112
|
-
image: {
|
|
113
|
-
id: cartItem.product.thumbnail.label,
|
|
114
|
-
url: cartItem.product.thumbnail.url,
|
|
115
|
-
label: cartItem.product.thumbnail.label,
|
|
116
|
-
},
|
|
117
|
-
in_stock: cartItem.product.stock_status === MagentoProductStockStatusEnum.InStock,
|
|
118
|
-
discounts: cartItem.prices.discounts?.map(discount => ({
|
|
119
|
-
amount: discount.amount?.value,
|
|
120
|
-
label: discount.label,
|
|
121
|
-
})) || [],
|
|
122
|
-
// TODO: implement
|
|
123
|
-
parent_item_id: null,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function transformBundleCartItemOption(option) {
|
|
128
|
-
return {
|
|
129
|
-
id: String(option.values[0].id),
|
|
130
|
-
option_label: option.label,
|
|
131
|
-
value_label: option.values[0].label,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Transforms a MagentoBundleCartItem into a DaffCartItem.
|
|
136
|
-
*
|
|
137
|
-
* @param response the response from a magento cart query.
|
|
138
|
-
*/
|
|
139
|
-
function transformMagentoBundleCartItem(bundleCartItem) {
|
|
140
|
-
return {
|
|
141
|
-
...transformMagentoSimpleCartItem(bundleCartItem),
|
|
142
|
-
type: DaffCartItemInputType.Composite,
|
|
143
|
-
options: bundleCartItem.bundle_options.map(transformBundleCartItemOption),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function transformConfigurableCartItemAttribute(option) {
|
|
148
|
-
return {
|
|
149
|
-
attribute_label: option.option_label,
|
|
150
|
-
value_label: option.value_label,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Transforms a MagentoConfigurableCartItem into a DaffCartItem.
|
|
155
|
-
*
|
|
156
|
-
* @param response the response from a magento cart query.
|
|
157
|
-
*/
|
|
158
|
-
function transformMagentoConfigurableCartItem(configurableCartItem) {
|
|
159
|
-
return {
|
|
160
|
-
...transformMagentoSimpleCartItem(configurableCartItem),
|
|
161
|
-
type: DaffCartItemInputType.Configurable,
|
|
162
|
-
attributes: configurableCartItem.configurable_options.map(transformConfigurableCartItemAttribute),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
var MagentoCartItemTypeEnum;
|
|
167
|
-
(function (MagentoCartItemTypeEnum) {
|
|
168
|
-
MagentoCartItemTypeEnum["Simple"] = "SimpleCartItem";
|
|
169
|
-
MagentoCartItemTypeEnum["Bundle"] = "BundleCartItem";
|
|
170
|
-
MagentoCartItemTypeEnum["Configurable"] = "ConfigurableCartItem";
|
|
171
|
-
})(MagentoCartItemTypeEnum || (MagentoCartItemTypeEnum = {}));
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* The standard transform for a magento cart item.
|
|
175
|
-
*/
|
|
176
|
-
const daffTransformMagentoCartItem = (cartItem) => {
|
|
177
|
-
switch (cartItem.__typename) {
|
|
178
|
-
case MagentoCartItemTypeEnum.Bundle:
|
|
179
|
-
return transformMagentoBundleCartItem(cartItem);
|
|
180
|
-
case MagentoCartItemTypeEnum.Configurable:
|
|
181
|
-
return transformMagentoConfigurableCartItem(cartItem);
|
|
182
|
-
case MagentoCartItemTypeEnum.Simple:
|
|
183
|
-
default:
|
|
184
|
-
return transformMagentoSimpleCartItem(cartItem);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* Transforms the MagentoCartItem into a DaffCartItem using the provided transforms.
|
|
189
|
-
*/
|
|
190
|
-
const transformMagentoCartItem = (daffCartItem, cartItem, transforms = []) => transforms.reduce((item, transform) => transform(item, cartItem), daffCartItem);
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Transforms magento carts into an object usable by daffodil.
|
|
194
|
-
*/
|
|
195
|
-
class DaffMagentoCartPaymentTransformer {
|
|
196
|
-
/**
|
|
197
|
-
* Transforms the magento CartPayment from the magento cart query into a DaffCartPaymentMethod.
|
|
198
|
-
*
|
|
199
|
-
* @param responsePayment - the response from a magento cart query.
|
|
200
|
-
*/
|
|
201
|
-
transform(responsePayment) {
|
|
202
|
-
return responsePayment ? {
|
|
203
|
-
method: responsePayment.code,
|
|
204
|
-
} : null;
|
|
205
|
-
}
|
|
206
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentTransformer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
207
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentTransformer, providedIn: 'root' }); }
|
|
208
|
-
}
|
|
209
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentTransformer, decorators: [{
|
|
210
|
-
type: Injectable,
|
|
211
|
-
args: [{
|
|
212
|
-
providedIn: 'root',
|
|
213
|
-
}]
|
|
214
|
-
}] });
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Transforms magento cart shipping methods into an object usable by daffodil.
|
|
218
|
-
*/
|
|
219
|
-
class DaffMagentoCartShippingRateTransformer {
|
|
220
|
-
/**
|
|
221
|
-
* Transforms the magento shipping method from the magento cart query into a DaffCartShippingRate.
|
|
222
|
-
*
|
|
223
|
-
* @param shippingMethod the shippingMethod from a magento cart query.
|
|
224
|
-
*/
|
|
225
|
-
transform(shippingMethod) {
|
|
226
|
-
return shippingMethod ? {
|
|
227
|
-
carrier: shippingMethod.carrier_code,
|
|
228
|
-
carrier_title: shippingMethod.carrier_title,
|
|
229
|
-
price: shippingMethod.amount.value,
|
|
230
|
-
method_code: shippingMethod.method_code,
|
|
231
|
-
method_title: shippingMethod.method_title,
|
|
232
|
-
id: shippingMethod.method_code,
|
|
233
|
-
// TODO: implement
|
|
234
|
-
method_description: null,
|
|
235
|
-
} : null;
|
|
236
|
-
}
|
|
237
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingRateTransformer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
238
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingRateTransformer, providedIn: 'root' }); }
|
|
239
|
-
}
|
|
240
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingRateTransformer, decorators: [{
|
|
241
|
-
type: Injectable,
|
|
242
|
-
args: [{
|
|
243
|
-
providedIn: 'root',
|
|
244
|
-
}]
|
|
245
|
-
}] });
|
|
246
|
-
|
|
247
|
-
function validateSelectedShippingAddress(cart) {
|
|
248
|
-
return !!cart.shipping_addresses?.[0]?.selected_shipping_method?.amount;
|
|
249
|
-
}
|
|
250
|
-
function transformCartTotals(cart) {
|
|
251
|
-
const totalTax = cart.prices.applied_taxes ? cart.prices.applied_taxes.reduce((acc, tax) => (daffAdd(acc, tax.amount.value)), 0) : 0;
|
|
252
|
-
return {
|
|
253
|
-
totals: {
|
|
254
|
-
[DaffCartTotalTypeEnum.grandTotal]: {
|
|
255
|
-
name: DaffCartTotalTypeEnum.grandTotal,
|
|
256
|
-
label: 'Grand Total',
|
|
257
|
-
value: cart.prices.grand_total.value,
|
|
258
|
-
order: 0,
|
|
259
|
-
},
|
|
260
|
-
[DaffCartTotalTypeEnum.subtotalExcludingTax]: {
|
|
261
|
-
name: DaffCartTotalTypeEnum.subtotalExcludingTax,
|
|
262
|
-
label: 'Subtotal Excluding Tax',
|
|
263
|
-
value: cart.prices.subtotal_excluding_tax.value,
|
|
264
|
-
order: 1,
|
|
265
|
-
},
|
|
266
|
-
[DaffCartTotalTypeEnum.subtotalIncludingTax]: {
|
|
267
|
-
name: DaffCartTotalTypeEnum.subtotalIncludingTax,
|
|
268
|
-
label: 'Subtotal Including Tax',
|
|
269
|
-
value: cart.prices.subtotal_including_tax.value,
|
|
270
|
-
order: 2,
|
|
271
|
-
},
|
|
272
|
-
[DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax]: {
|
|
273
|
-
name: DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax,
|
|
274
|
-
label: 'Subtotal with Discount Excluding Tax',
|
|
275
|
-
value: cart.prices.subtotal_with_discount_excluding_tax.value,
|
|
276
|
-
order: 3,
|
|
277
|
-
},
|
|
278
|
-
[DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax]: {
|
|
279
|
-
name: DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax,
|
|
280
|
-
label: 'Subtotal with Discount Including Tax',
|
|
281
|
-
value: cart.prices.subtotal_with_discount_excluding_tax.value ?
|
|
282
|
-
daffAdd(cart.prices.subtotal_with_discount_excluding_tax.value, totalTax) :
|
|
283
|
-
cart.prices.subtotal_with_discount_excluding_tax.value,
|
|
284
|
-
order: 4,
|
|
285
|
-
},
|
|
286
|
-
[DaffCartTotalTypeEnum.tax]: {
|
|
287
|
-
name: DaffCartTotalTypeEnum.tax,
|
|
288
|
-
label: 'Tax',
|
|
289
|
-
value: totalTax,
|
|
290
|
-
order: 5,
|
|
291
|
-
},
|
|
292
|
-
[DaffCartTotalTypeEnum.discount]: {
|
|
293
|
-
name: DaffCartTotalTypeEnum.discount,
|
|
294
|
-
label: 'Discounts',
|
|
295
|
-
value: cart.prices.discounts ? daffAdd(...cart.prices.discounts.map((discount) => discount.amount.value)) : 0,
|
|
296
|
-
order: 6,
|
|
297
|
-
},
|
|
298
|
-
[DaffCartTotalTypeEnum.shipping]: {
|
|
299
|
-
name: DaffCartTotalTypeEnum.shipping,
|
|
300
|
-
label: 'Shipping',
|
|
301
|
-
value: validateSelectedShippingAddress(cart) ? cart.shipping_addresses[0].selected_shipping_method.amount.value : null,
|
|
302
|
-
order: 7,
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Transforms magento addresses into an object usable by daffodil.
|
|
310
|
-
*/
|
|
311
|
-
class DaffMagentoShippingAddressTransformer {
|
|
312
|
-
constructor(addressTransformer) {
|
|
313
|
-
this.addressTransformer = addressTransformer;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Transforms the magento MagentoCart from the magento cart query into a DaffCartAddress.
|
|
317
|
-
*
|
|
318
|
-
* @param address the address from a magento cart query.
|
|
319
|
-
*/
|
|
320
|
-
transform(address) {
|
|
321
|
-
return address
|
|
322
|
-
? this.addressTransformer.transform(address)
|
|
323
|
-
: null;
|
|
324
|
-
}
|
|
325
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingAddressTransformer, deps: [{ token: DaffMagentoCartAddressTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
326
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingAddressTransformer, providedIn: 'root' }); }
|
|
327
|
-
}
|
|
328
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingAddressTransformer, decorators: [{
|
|
329
|
-
type: Injectable,
|
|
330
|
-
args: [{
|
|
331
|
-
providedIn: 'root',
|
|
332
|
-
}]
|
|
333
|
-
}], ctorParameters: () => [{ type: DaffMagentoCartAddressTransformer }] });
|
|
334
|
-
|
|
335
|
-
const {
|
|
336
|
-
/**
|
|
337
|
-
* An multi-provider injection token for providing extra GraphQL fragments that will be spread into cart queries.
|
|
338
|
-
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces.
|
|
339
|
-
* The data will appear in DaffCart#extra_attributes.
|
|
340
|
-
*
|
|
341
|
-
* Fragment structure is platform-specific and this feature should be used with care.
|
|
342
|
-
*
|
|
343
|
-
* This can increase query complexity above the Magento default of 300.
|
|
344
|
-
* Daffodil only guarantees that stock queries don't exceed the limit of 300.
|
|
345
|
-
* Apps using this token should therefore increase the query complexity limit
|
|
346
|
-
* to accommodate the extra complexity contributed by the provided fragments.
|
|
347
|
-
*/
|
|
348
|
-
token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS,
|
|
349
|
-
/**
|
|
350
|
-
* Provider function for {@link DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS}.
|
|
351
|
-
*/
|
|
352
|
-
provider: provideDaffCartMagentoExtraCartFragments, factoryProvider: provideDaffCartMagentoExtraCartFragmentFactories, } = createMultiInjectionToken('DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS');
|
|
353
|
-
|
|
354
|
-
const {
|
|
355
|
-
/**
|
|
356
|
-
* A multi-provider injection token for providing cart item transform logic in the Magento driver.
|
|
357
|
-
* It is run after the standard transforms and passed both the current transformed Daffodil cart item and the Magento cart item.
|
|
358
|
-
*/
|
|
359
|
-
token: DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,
|
|
360
|
-
/**
|
|
361
|
-
* Provides cart item transforms for the Magento cart driver.
|
|
362
|
-
*
|
|
363
|
-
* See {@link DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS}.
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* ```ts
|
|
367
|
-
* providers: [
|
|
368
|
-
* ...provideDaffCartMagentoCartItemTransforms(
|
|
369
|
-
* myCartItemTransform
|
|
370
|
-
* )
|
|
371
|
-
* ]
|
|
372
|
-
* ```
|
|
373
|
-
*/
|
|
374
|
-
provider: provideDaffCartMagentoCartItemTransforms, factoryProvider: provideDaffCartMagentoCartItemTransformFactories, } = createMultiInjectionToken('DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS');
|
|
375
|
-
|
|
376
|
-
const {
|
|
377
|
-
/**
|
|
378
|
-
* A multi-provider injection token for providing cart transform logic in the Magento driver.
|
|
379
|
-
* It is run after the standard transforms and passed both the current transformed Daffodil cart and the Magento cart.
|
|
380
|
-
*/
|
|
381
|
-
token: DAFF_CART_MAGENTO_CART_TRANSFORMS,
|
|
382
|
-
/**
|
|
383
|
-
* Provides cart transforms for the Magento cart driver.
|
|
384
|
-
*
|
|
385
|
-
* See {@link DAFF_CART_MAGENTO_CART_TRANSFORMS}.
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* ```ts
|
|
389
|
-
* providers: [
|
|
390
|
-
* ...provideDaffCartMagentoCartTransforms(
|
|
391
|
-
* myCartTransform
|
|
392
|
-
* )
|
|
393
|
-
* ]
|
|
394
|
-
* ```
|
|
395
|
-
*/
|
|
396
|
-
provider: provideDaffCartMagentoCartTransforms, factoryProvider: provideDaffCartMagentoCartTransformFactories, } = createMultiInjectionToken('DAFF_CART_MAGENTO_CART_TRANSFORMS');
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Transforms magento carts into an object usable by daffodil.
|
|
400
|
-
*/
|
|
401
|
-
class DaffMagentoCartTransformer {
|
|
402
|
-
constructor(shippingAddressTransformer, billingAddressTransformer, paymentTransformer, shippingRateTransformer, cartItemTransforms, cartTransforms) {
|
|
403
|
-
this.shippingAddressTransformer = shippingAddressTransformer;
|
|
404
|
-
this.billingAddressTransformer = billingAddressTransformer;
|
|
405
|
-
this.paymentTransformer = paymentTransformer;
|
|
406
|
-
this.shippingRateTransformer = shippingRateTransformer;
|
|
407
|
-
this.cartItemTransforms = cartItemTransforms;
|
|
408
|
-
this.cartTransforms = cartTransforms;
|
|
409
|
-
}
|
|
410
|
-
transformShippingAddress(cart) {
|
|
411
|
-
return {
|
|
412
|
-
shipping_address: cart.shipping_addresses[0]
|
|
413
|
-
? this.shippingAddressTransformer.transform({
|
|
414
|
-
...cart.shipping_addresses[0],
|
|
415
|
-
email: cart.email,
|
|
416
|
-
})
|
|
417
|
-
: null,
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
transformBillingAddress(cart) {
|
|
421
|
-
return {
|
|
422
|
-
billing_address: cart.billing_address
|
|
423
|
-
? this.billingAddressTransformer.transform({
|
|
424
|
-
...cart.billing_address,
|
|
425
|
-
email: cart.email,
|
|
426
|
-
})
|
|
427
|
-
: null,
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
transformCartItems(cart) {
|
|
431
|
-
return {
|
|
432
|
-
// TODO: extract into own transforms
|
|
433
|
-
items: cart.items.filter(item => !!item).map(item => transformMagentoCartItem(daffTransformMagentoCartItem(item), item, this.cartItemTransforms)),
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
transformCoupons(cart) {
|
|
437
|
-
return {
|
|
438
|
-
coupons: cart.applied_coupons
|
|
439
|
-
? cart.applied_coupons.map(daffMagentoCouponTransform)
|
|
440
|
-
: [],
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
transformPayment(cart) {
|
|
444
|
-
return {
|
|
445
|
-
payment: this.paymentTransformer.transform(cart.selected_payment_method),
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
transformShippingInformation(cart) {
|
|
449
|
-
return {
|
|
450
|
-
shipping_information: cart.shipping_addresses[0]
|
|
451
|
-
? this.shippingRateTransformer.transform(cart.shipping_addresses[0].selected_shipping_method)
|
|
452
|
-
: null,
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
transformShippingMethods(cart) {
|
|
456
|
-
return {
|
|
457
|
-
available_shipping_methods: cart.shipping_addresses[0] && cart.shipping_addresses[0].available_shipping_methods
|
|
458
|
-
? cart.shipping_addresses[0].available_shipping_methods.map(method => this.shippingRateTransformer.transform(method))
|
|
459
|
-
: [],
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
transformPaymentMethods(cart) {
|
|
463
|
-
return {
|
|
464
|
-
available_payment_methods: cart.available_payment_methods.map(method => this.paymentTransformer.transform(method)),
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Transforms the magento MagentoCart from the magento cart query into a DaffCart.
|
|
469
|
-
*
|
|
470
|
-
* @param cart the cart from a magento cart query.
|
|
471
|
-
*/
|
|
472
|
-
transform(cart) {
|
|
473
|
-
return cart ? this.cartTransforms.reduce((daffCart, transform) => transform(daffCart, cart), {
|
|
474
|
-
extra_attributes: cart,
|
|
475
|
-
...this.transformCartItems(cart),
|
|
476
|
-
...this.transformBillingAddress(cart),
|
|
477
|
-
...this.transformShippingAddress(cart),
|
|
478
|
-
...this.transformCoupons(cart),
|
|
479
|
-
...this.transformPayment(cart),
|
|
480
|
-
...transformCartTotals(cart),
|
|
481
|
-
...this.transformShippingInformation(cart),
|
|
482
|
-
...this.transformShippingMethods(cart),
|
|
483
|
-
...this.transformPaymentMethods(cart),
|
|
484
|
-
id: cart.id,
|
|
485
|
-
}) : null;
|
|
486
|
-
}
|
|
487
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartTransformer, deps: [{ token: DaffMagentoShippingAddressTransformer }, { token: DaffMagentoBillingAddressTransformer }, { token: DaffMagentoCartPaymentTransformer }, { token: DaffMagentoCartShippingRateTransformer }, { token: DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS }, { token: DAFF_CART_MAGENTO_CART_TRANSFORMS }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
488
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartTransformer, providedIn: 'root' }); }
|
|
489
|
-
}
|
|
490
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartTransformer, decorators: [{
|
|
491
|
-
type: Injectable,
|
|
492
|
-
args: [{
|
|
493
|
-
providedIn: 'root',
|
|
494
|
-
}]
|
|
495
|
-
}], ctorParameters: () => [{ type: DaffMagentoShippingAddressTransformer }, { type: DaffMagentoBillingAddressTransformer }, { type: DaffMagentoCartPaymentTransformer }, { type: DaffMagentoCartShippingRateTransformer }, { type: undefined, decorators: [{
|
|
496
|
-
type: Inject,
|
|
497
|
-
args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS]
|
|
498
|
-
}] }, { type: undefined, decorators: [{
|
|
499
|
-
type: Inject,
|
|
500
|
-
args: [DAFF_CART_MAGENTO_CART_TRANSFORMS]
|
|
501
|
-
}] }] });
|
|
502
|
-
|
|
503
|
-
class DaffMagentoCartAddressInputTransformer {
|
|
504
|
-
transform(cartAddress) {
|
|
505
|
-
const street = [cartAddress.street];
|
|
506
|
-
if (cartAddress.street2) {
|
|
507
|
-
street.push(cartAddress.street2);
|
|
508
|
-
}
|
|
509
|
-
return {
|
|
510
|
-
city: cartAddress.city,
|
|
511
|
-
country_code: cartAddress.country,
|
|
512
|
-
firstname: cartAddress.firstname,
|
|
513
|
-
lastname: cartAddress.lastname,
|
|
514
|
-
postcode: cartAddress.postcode,
|
|
515
|
-
region_id: Number(cartAddress.region),
|
|
516
|
-
save_in_address_book: false,
|
|
517
|
-
street,
|
|
518
|
-
telephone: cartAddress.telephone,
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressInputTransformer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
522
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressInputTransformer, providedIn: 'root' }); }
|
|
523
|
-
}
|
|
524
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressInputTransformer, decorators: [{
|
|
525
|
-
type: Injectable,
|
|
526
|
-
args: [{
|
|
527
|
-
providedIn: 'root',
|
|
528
|
-
}]
|
|
529
|
-
}] });
|
|
530
|
-
|
|
531
|
-
class DaffMagentoShippingAddressInputTransformer {
|
|
532
|
-
constructor(cartAddressTransformer) {
|
|
533
|
-
this.cartAddressTransformer = cartAddressTransformer;
|
|
534
|
-
}
|
|
535
|
-
transform(cartAddress) {
|
|
536
|
-
return cartAddress.id
|
|
537
|
-
? {
|
|
538
|
-
address: null,
|
|
539
|
-
customer_address_id: Number(cartAddress.id),
|
|
540
|
-
}
|
|
541
|
-
: {
|
|
542
|
-
address: this.cartAddressTransformer.transform(cartAddress),
|
|
543
|
-
customer_address_id: null,
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingAddressInputTransformer, deps: [{ token: DaffMagentoCartAddressInputTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
547
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingAddressInputTransformer, providedIn: 'root' }); }
|
|
548
|
-
}
|
|
549
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingAddressInputTransformer, decorators: [{
|
|
550
|
-
type: Injectable,
|
|
551
|
-
args: [{
|
|
552
|
-
providedIn: 'root',
|
|
553
|
-
}]
|
|
554
|
-
}], ctorParameters: () => [{ type: DaffMagentoCartAddressInputTransformer }] });
|
|
555
|
-
|
|
556
|
-
class DaffMagentoBillingAddressInputTransformer {
|
|
557
|
-
constructor(cartAddressTransformer) {
|
|
558
|
-
this.cartAddressTransformer = cartAddressTransformer;
|
|
559
|
-
}
|
|
560
|
-
transform(cartAddress) {
|
|
561
|
-
return cartAddress.id
|
|
562
|
-
? {
|
|
563
|
-
address: null,
|
|
564
|
-
customer_address_id: Number(cartAddress.id),
|
|
565
|
-
}
|
|
566
|
-
: {
|
|
567
|
-
address: this.cartAddressTransformer.transform(cartAddress),
|
|
568
|
-
customer_address_id: null,
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoBillingAddressInputTransformer, deps: [{ token: DaffMagentoCartAddressInputTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
572
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoBillingAddressInputTransformer, providedIn: 'root' }); }
|
|
573
|
-
}
|
|
574
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoBillingAddressInputTransformer, decorators: [{
|
|
575
|
-
type: Injectable,
|
|
576
|
-
args: [{
|
|
577
|
-
providedIn: 'root',
|
|
578
|
-
}]
|
|
579
|
-
}], ctorParameters: () => [{ type: DaffMagentoCartAddressInputTransformer }] });
|
|
580
|
-
|
|
581
|
-
class DaffMagentoCartItemUpdateInputTransformer {
|
|
582
|
-
transform(item) {
|
|
583
|
-
return {
|
|
584
|
-
quantity: item.qty,
|
|
585
|
-
cart_item_id: Number(item.id),
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartItemUpdateInputTransformer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
589
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartItemUpdateInputTransformer, providedIn: 'root' }); }
|
|
590
|
-
}
|
|
591
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartItemUpdateInputTransformer, decorators: [{
|
|
592
|
-
type: Injectable,
|
|
593
|
-
args: [{
|
|
594
|
-
providedIn: 'root',
|
|
595
|
-
}]
|
|
596
|
-
}] });
|
|
597
|
-
|
|
598
|
-
class DaffMagentoPaymentMethodInputTransformer {
|
|
599
|
-
transform(payment) {
|
|
600
|
-
return {
|
|
601
|
-
...payment.payment_info,
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoPaymentMethodInputTransformer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
605
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoPaymentMethodInputTransformer, providedIn: 'root' }); }
|
|
606
|
-
}
|
|
607
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoPaymentMethodInputTransformer, decorators: [{
|
|
608
|
-
type: Injectable,
|
|
609
|
-
args: [{
|
|
610
|
-
providedIn: 'root',
|
|
611
|
-
}]
|
|
612
|
-
}] });
|
|
613
|
-
|
|
614
|
-
class DaffMagentoShippingMethodInputTransformer {
|
|
615
|
-
transform(method) {
|
|
616
|
-
return {
|
|
617
|
-
carrier_code: method.carrier,
|
|
618
|
-
method_code: method.method_code,
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingMethodInputTransformer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
622
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingMethodInputTransformer, providedIn: 'root' }); }
|
|
623
|
-
}
|
|
624
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoShippingMethodInputTransformer, decorators: [{
|
|
625
|
-
type: Injectable,
|
|
626
|
-
args: [{
|
|
627
|
-
providedIn: 'root',
|
|
628
|
-
}]
|
|
629
|
-
}] });
|
|
630
|
-
|
|
631
|
-
var MagentoCartUserInputErrorType;
|
|
632
|
-
(function (MagentoCartUserInputErrorType) {
|
|
633
|
-
MagentoCartUserInputErrorType["PRODUCT_NOT_FOUND"] = "PRODUCT_NOT_FOUND";
|
|
634
|
-
MagentoCartUserInputErrorType["NOT_SALABLE"] = "NOT_SALABLE";
|
|
635
|
-
MagentoCartUserInputErrorType["INSUFFICIENT_STOCK"] = "INSUFFICIENT_STOCK";
|
|
636
|
-
MagentoCartUserInputErrorType["UNDEFINED"] = "UNDEFINED";
|
|
637
|
-
})(MagentoCartUserInputErrorType || (MagentoCartUserInputErrorType = {}));
|
|
638
|
-
|
|
639
|
-
const cartCouponFragment = gql `
|
|
640
|
-
fragment cartCoupon on AppliedCoupon {
|
|
641
|
-
code
|
|
642
|
-
}
|
|
643
|
-
`;
|
|
644
|
-
|
|
645
|
-
const cartAddressFragment = gql `
|
|
646
|
-
fragment cartAddress on CartAddressInterface {
|
|
647
|
-
customer_address_id
|
|
648
|
-
city
|
|
649
|
-
country {
|
|
650
|
-
code
|
|
651
|
-
label
|
|
652
|
-
}
|
|
653
|
-
firstname
|
|
654
|
-
lastname
|
|
655
|
-
postcode
|
|
656
|
-
region {
|
|
657
|
-
code
|
|
658
|
-
region_id
|
|
659
|
-
}
|
|
660
|
-
street
|
|
661
|
-
telephone
|
|
662
|
-
company
|
|
663
|
-
}
|
|
664
|
-
`;
|
|
665
|
-
|
|
666
|
-
const cartItemProductFragment = gql `
|
|
667
|
-
fragment cartItemProduct on ProductInterface {
|
|
668
|
-
id
|
|
669
|
-
uid
|
|
670
|
-
name
|
|
671
|
-
sku
|
|
672
|
-
url_key
|
|
673
|
-
url_suffix
|
|
674
|
-
thumbnail {
|
|
675
|
-
label
|
|
676
|
-
url
|
|
677
|
-
}
|
|
678
|
-
stock_status
|
|
679
|
-
}
|
|
680
|
-
`;
|
|
681
|
-
const cartItemFragment = gql `
|
|
682
|
-
fragment cartItem on CartItemInterface {
|
|
683
|
-
__typename
|
|
684
|
-
id
|
|
685
|
-
uid
|
|
686
|
-
product {
|
|
687
|
-
...cartItemProduct
|
|
688
|
-
}
|
|
689
|
-
quantity
|
|
690
|
-
prices {
|
|
691
|
-
price {
|
|
692
|
-
...moneyFragment
|
|
693
|
-
}
|
|
694
|
-
row_total {
|
|
695
|
-
...moneyFragment
|
|
696
|
-
}
|
|
697
|
-
discounts {
|
|
698
|
-
amount {
|
|
699
|
-
...moneyFragment
|
|
700
|
-
}
|
|
701
|
-
label
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
...on ConfigurableCartItem {
|
|
705
|
-
configurable_options {
|
|
706
|
-
option_label
|
|
707
|
-
value_label
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
...on BundleCartItem {
|
|
711
|
-
bundle_options {
|
|
712
|
-
id
|
|
713
|
-
label
|
|
714
|
-
type
|
|
715
|
-
values {
|
|
716
|
-
id
|
|
717
|
-
label
|
|
718
|
-
price
|
|
719
|
-
quantity
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
${cartItemProductFragment}
|
|
725
|
-
${magentoMoneyFragment}
|
|
726
|
-
`;
|
|
727
|
-
|
|
728
|
-
const availablePaymentMethodFragment = gql `
|
|
729
|
-
fragment availablePaymentMethod on AvailablePaymentMethod {
|
|
730
|
-
code
|
|
731
|
-
title
|
|
732
|
-
}
|
|
733
|
-
`;
|
|
734
|
-
|
|
735
|
-
const selectedPaymentMethodFragment = gql `
|
|
736
|
-
fragment selectedPaymentMethod on SelectedPaymentMethod {
|
|
737
|
-
code
|
|
738
|
-
title
|
|
739
|
-
purchase_order_number
|
|
740
|
-
}
|
|
741
|
-
`;
|
|
742
|
-
|
|
743
|
-
const availableShippingMethodFragment = gql `
|
|
744
|
-
fragment availableShippingMethod on AvailableShippingMethod {
|
|
745
|
-
carrier_code
|
|
746
|
-
method_code
|
|
747
|
-
carrier_title
|
|
748
|
-
method_title
|
|
749
|
-
amount {
|
|
750
|
-
...moneyFragment
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
${magentoMoneyFragment}
|
|
754
|
-
`;
|
|
755
|
-
|
|
756
|
-
const selectedShippingMethodFragment = gql `
|
|
757
|
-
fragment selectedShippingMethod on SelectedShippingMethod {
|
|
758
|
-
carrier_code
|
|
759
|
-
method_code
|
|
760
|
-
carrier_title
|
|
761
|
-
method_title
|
|
762
|
-
amount {
|
|
763
|
-
...moneyFragment
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
${magentoMoneyFragment}
|
|
767
|
-
`;
|
|
768
|
-
|
|
769
|
-
const pricesFragment = gql `
|
|
770
|
-
fragment prices on CartPrices {
|
|
771
|
-
grand_total {
|
|
772
|
-
...moneyFragment
|
|
773
|
-
}
|
|
774
|
-
subtotal_excluding_tax {
|
|
775
|
-
...moneyFragment
|
|
776
|
-
}
|
|
777
|
-
subtotal_including_tax {
|
|
778
|
-
...moneyFragment
|
|
779
|
-
}
|
|
780
|
-
subtotal_with_discount_excluding_tax {
|
|
781
|
-
...moneyFragment
|
|
782
|
-
}
|
|
783
|
-
applied_taxes {
|
|
784
|
-
amount {
|
|
785
|
-
...moneyFragment
|
|
786
|
-
}
|
|
787
|
-
label
|
|
788
|
-
}
|
|
789
|
-
discounts {
|
|
790
|
-
amount {
|
|
791
|
-
...moneyFragment
|
|
792
|
-
}
|
|
793
|
-
label
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
${magentoMoneyFragment}
|
|
797
|
-
`;
|
|
798
|
-
|
|
799
|
-
const cartFragment = gql `
|
|
800
|
-
fragment cart on Cart {
|
|
801
|
-
id
|
|
802
|
-
email
|
|
803
|
-
billing_address {
|
|
804
|
-
...cartAddress
|
|
805
|
-
}
|
|
806
|
-
shipping_addresses {
|
|
807
|
-
...cartAddress
|
|
808
|
-
... on ShippingCartAddress {
|
|
809
|
-
selected_shipping_method {
|
|
810
|
-
...selectedShippingMethod
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
available_shipping_methods {
|
|
814
|
-
amount {
|
|
815
|
-
currency
|
|
816
|
-
value
|
|
817
|
-
}
|
|
818
|
-
carrier_code
|
|
819
|
-
method_code
|
|
820
|
-
carrier_title
|
|
821
|
-
method_title
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
items {
|
|
825
|
-
...cartItem
|
|
826
|
-
}
|
|
827
|
-
available_payment_methods {
|
|
828
|
-
...availablePaymentMethod
|
|
829
|
-
}
|
|
830
|
-
selected_payment_method {
|
|
831
|
-
...selectedPaymentMethod
|
|
832
|
-
}
|
|
833
|
-
applied_coupons {
|
|
834
|
-
...cartCoupon
|
|
835
|
-
}
|
|
836
|
-
prices {
|
|
837
|
-
...prices
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
${cartAddressFragment}
|
|
841
|
-
${availablePaymentMethodFragment}
|
|
842
|
-
${selectedPaymentMethodFragment}
|
|
843
|
-
${selectedShippingMethodFragment}
|
|
844
|
-
${cartItemFragment}
|
|
845
|
-
${pricesFragment}
|
|
846
|
-
${cartCouponFragment}
|
|
847
|
-
`;
|
|
848
|
-
|
|
849
|
-
const magentoCartUserError = gql `
|
|
850
|
-
fragment cartUserError on CartUserInputError {
|
|
851
|
-
code
|
|
852
|
-
message
|
|
853
|
-
}
|
|
854
|
-
`;
|
|
855
|
-
|
|
856
|
-
const addCartItem = (extraCartFragments = []) => gql `
|
|
857
|
-
mutation MagentoAddCartItem($cartId: String!, $input: CartItemInput!) {
|
|
858
|
-
addProductsToCart(
|
|
859
|
-
cartId: $cartId,
|
|
860
|
-
cartItems: [$input]
|
|
861
|
-
) {
|
|
862
|
-
cart {
|
|
863
|
-
...cart
|
|
864
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
865
|
-
}
|
|
866
|
-
user_errors {
|
|
867
|
-
...cartUserError
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
${cartFragment}
|
|
872
|
-
${magentoCartUserError}
|
|
873
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
874
|
-
`;
|
|
875
|
-
|
|
876
|
-
const applyCoupon = (extraCartFragments = []) => gql `
|
|
877
|
-
mutation MagentoApplyCoupon($cartId: String!, $couponCode: String!) {
|
|
878
|
-
applyCouponToCart(
|
|
879
|
-
input: {
|
|
880
|
-
cart_id: $cartId,
|
|
881
|
-
coupon_code: $couponCode
|
|
882
|
-
}
|
|
883
|
-
) {
|
|
884
|
-
cart {
|
|
885
|
-
...cart
|
|
886
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
${cartFragment}
|
|
891
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
892
|
-
`;
|
|
893
|
-
|
|
894
|
-
const createCart = gql `
|
|
895
|
-
mutation MagentoCreateCart {
|
|
896
|
-
createEmptyCart
|
|
897
|
-
}
|
|
898
|
-
`;
|
|
899
|
-
|
|
900
|
-
const getBillingAddress = (extraCartFragments = []) => gql `
|
|
901
|
-
query MagentoGetBillingAddress($cartId: String!) {
|
|
902
|
-
cart(cart_id: $cartId) {
|
|
903
|
-
billing_address {
|
|
904
|
-
...cartAddress
|
|
905
|
-
}
|
|
906
|
-
email
|
|
907
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
${cartAddressFragment}
|
|
911
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
912
|
-
`;
|
|
913
|
-
|
|
914
|
-
const getCart = (extraCartFragments = []) => gql `
|
|
915
|
-
query MagentoGetCart($cartId: String!) {
|
|
916
|
-
cart(cart_id: $cartId) {
|
|
917
|
-
...cart
|
|
918
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
${cartFragment}
|
|
922
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
923
|
-
`;
|
|
924
|
-
|
|
925
|
-
const getSelectedPaymentMethod = (extraCartFragments = []) => gql `
|
|
926
|
-
query MagentoGetSelectedPaymentMethod($cartId: String!) {
|
|
927
|
-
cart(cart_id: $cartId) {
|
|
928
|
-
selected_payment_method {
|
|
929
|
-
...selectedPaymentMethod
|
|
930
|
-
}
|
|
931
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
${selectedPaymentMethodFragment}
|
|
935
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
936
|
-
`;
|
|
937
|
-
|
|
938
|
-
const getSelectedShippingMethod = (extraCartFragments = []) => gql `
|
|
939
|
-
query MagentoGetSelectedShippingMethod($cartId: String!) {
|
|
940
|
-
cart(cart_id: $cartId) {
|
|
941
|
-
shipping_addresses {
|
|
942
|
-
selected_shipping_method {
|
|
943
|
-
...selectedShippingMethod
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
${selectedShippingMethodFragment}
|
|
950
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
951
|
-
`;
|
|
952
|
-
|
|
953
|
-
const getShippingAddress = (extraCartFragments = []) => gql `
|
|
954
|
-
query MagentoGetShippingAddress($cartId: String!) {
|
|
955
|
-
cart(cart_id: $cartId) {
|
|
956
|
-
shipping_addresses {
|
|
957
|
-
...cartAddress
|
|
958
|
-
}
|
|
959
|
-
email
|
|
960
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
${cartAddressFragment}
|
|
964
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
965
|
-
`;
|
|
966
|
-
|
|
967
|
-
const listCartCoupons = (extraCartFragments = []) => gql `
|
|
968
|
-
query MagentoListCartCoupons($cartId: String!) {
|
|
969
|
-
cart(cart_id: $cartId) {
|
|
970
|
-
applied_coupons {
|
|
971
|
-
...cartCoupon
|
|
972
|
-
}
|
|
973
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
${cartCouponFragment}
|
|
977
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
978
|
-
`;
|
|
979
|
-
|
|
980
|
-
const listCartItems = (extraCartFragments = []) => gql `
|
|
981
|
-
query MagentoListCartItems($cartId: String!) {
|
|
982
|
-
cart(cart_id: $cartId) {
|
|
983
|
-
items {
|
|
984
|
-
...cartItem
|
|
985
|
-
}
|
|
986
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
${cartItemFragment}
|
|
990
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
991
|
-
`;
|
|
992
|
-
|
|
993
|
-
const listPaymentMethods = (extraCartFragments = []) => gql `
|
|
994
|
-
query MagentoListPaymentMethods($cartId: String!) {
|
|
995
|
-
cart(cart_id: $cartId) {
|
|
996
|
-
available_payment_methods {
|
|
997
|
-
...availablePaymentMethod
|
|
998
|
-
}
|
|
999
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
${availablePaymentMethodFragment}
|
|
1003
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1004
|
-
`;
|
|
1005
|
-
|
|
1006
|
-
const listShippingMethods = (extraCartFragments = []) => gql `
|
|
1007
|
-
query MagentoListShippingMethods($cartId: String!) {
|
|
1008
|
-
cart(cart_id: $cartId) {
|
|
1009
|
-
id
|
|
1010
|
-
shipping_addresses {
|
|
1011
|
-
street
|
|
1012
|
-
available_shipping_methods {
|
|
1013
|
-
...availableShippingMethod
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
${availableShippingMethodFragment}
|
|
1020
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1021
|
-
`;
|
|
1022
|
-
|
|
1023
|
-
const magentoMergeCartsMutation = (extraCartFragments = []) => gql `
|
|
1024
|
-
mutation MagentoMergeCarts($source: String!, $destination: String) {
|
|
1025
|
-
mergeCarts(
|
|
1026
|
-
source_cart_id: $source,
|
|
1027
|
-
destination_cart_id: $destination
|
|
1028
|
-
) {
|
|
1029
|
-
...cart
|
|
1030
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
${cartFragment}
|
|
1034
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1035
|
-
`;
|
|
1036
|
-
|
|
1037
|
-
const placeOrder = gql `
|
|
1038
|
-
mutation MagentoPlaceOrder($cartId: String!) {
|
|
1039
|
-
placeOrder(
|
|
1040
|
-
input: {
|
|
1041
|
-
cart_id: $cartId
|
|
1042
|
-
}
|
|
1043
|
-
) {
|
|
1044
|
-
order {
|
|
1045
|
-
order_number
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
`;
|
|
1050
|
-
|
|
1051
|
-
const removeAllCoupons = (extraCartFragments = []) => gql `
|
|
1052
|
-
mutation MagentoRemoveAllCoupons($cartId: String!) {
|
|
1053
|
-
removeCouponFromCart(
|
|
1054
|
-
input: {
|
|
1055
|
-
cart_id: $cartId
|
|
1056
|
-
}
|
|
1057
|
-
) {
|
|
1058
|
-
cart {
|
|
1059
|
-
...cart
|
|
1060
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
${cartFragment}
|
|
1065
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1066
|
-
`;
|
|
1067
|
-
|
|
1068
|
-
const removeCartItem = (extraCartFragments = []) => gql `
|
|
1069
|
-
mutation MagentoRemoveCartItem($cartId: String!, $itemId: Int!) {
|
|
1070
|
-
removeItemFromCart(input: {
|
|
1071
|
-
cart_id: $cartId,
|
|
1072
|
-
cart_item_id: $itemId
|
|
1073
|
-
}) {
|
|
1074
|
-
cart {
|
|
1075
|
-
...cart
|
|
1076
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
${cartFragment}
|
|
1081
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1082
|
-
`;
|
|
1083
|
-
|
|
1084
|
-
const setSelectedPaymentMethodWithBillingAndEmail = (extraCartFragments = []) => gql `
|
|
1085
|
-
mutation MagentoSetSelectedPaymentMethodWithBillingAndEmail(
|
|
1086
|
-
$cartId: String!,
|
|
1087
|
-
$payment: PaymentMethodInput!,
|
|
1088
|
-
$address: BillingAddressInput!,
|
|
1089
|
-
$email: String!
|
|
1090
|
-
) {
|
|
1091
|
-
setBillingAddressOnCart(input: {
|
|
1092
|
-
cart_id: $cartId
|
|
1093
|
-
billing_address: $address
|
|
1094
|
-
}) {
|
|
1095
|
-
cart {
|
|
1096
|
-
id
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
setPaymentMethodOnCart(input: {
|
|
1100
|
-
cart_id: $cartId
|
|
1101
|
-
payment_method: $payment
|
|
1102
|
-
}) {
|
|
1103
|
-
cart {
|
|
1104
|
-
id
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
setGuestEmailOnCart(input: {
|
|
1108
|
-
cart_id: $cartId,
|
|
1109
|
-
email: $email
|
|
1110
|
-
}) {
|
|
1111
|
-
cart {
|
|
1112
|
-
...cart
|
|
1113
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
${cartFragment}
|
|
1118
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1119
|
-
`;
|
|
1120
|
-
|
|
1121
|
-
const setSelectedPaymentMethodWithBilling = (extraCartFragments = []) => gql `
|
|
1122
|
-
mutation MagentoSetSelectedPaymentMethodWithBilling(
|
|
1123
|
-
$cartId: String!,
|
|
1124
|
-
$payment: PaymentMethodInput!,
|
|
1125
|
-
$address: BillingAddressInput!
|
|
1126
|
-
) {
|
|
1127
|
-
setBillingAddressOnCart(input: {
|
|
1128
|
-
cart_id: $cartId
|
|
1129
|
-
billing_address: $address
|
|
1130
|
-
}) {
|
|
1131
|
-
cart {
|
|
1132
|
-
id
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
setPaymentMethodOnCart(input: {
|
|
1136
|
-
cart_id: $cartId
|
|
1137
|
-
payment_method: $payment
|
|
1138
|
-
}) {
|
|
1139
|
-
cart {
|
|
1140
|
-
...cart
|
|
1141
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
${cartFragment}
|
|
1146
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1147
|
-
`;
|
|
1148
|
-
|
|
1149
|
-
const setSelectedPaymentMethod = (extraCartFragments = []) => gql `
|
|
1150
|
-
mutation MagentoSetSelectedPaymentMethod($cartId: String!, $payment: PaymentMethodInput!) {
|
|
1151
|
-
setPaymentMethodOnCart(input: {
|
|
1152
|
-
cart_id: $cartId
|
|
1153
|
-
payment_method: $payment
|
|
1154
|
-
}) {
|
|
1155
|
-
cart {
|
|
1156
|
-
...cart
|
|
1157
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
${cartFragment}
|
|
1162
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1163
|
-
`;
|
|
1164
|
-
|
|
1165
|
-
const setSelectedShippingMethod = (extraCartFragments = []) => gql `
|
|
1166
|
-
mutation MagentoSetSelectedShippingMethod($cartId: String!, $method: ShippingMethodInput!) {
|
|
1167
|
-
setShippingMethodsOnCart(input: {
|
|
1168
|
-
cart_id: $cartId
|
|
1169
|
-
shipping_methods: [$method]
|
|
1170
|
-
}) {
|
|
1171
|
-
cart {
|
|
1172
|
-
...cart
|
|
1173
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
${cartFragment}
|
|
1178
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1179
|
-
`;
|
|
1180
|
-
|
|
1181
|
-
/**
|
|
1182
|
-
* Update the shipping and billing address of the cart.
|
|
1183
|
-
* At the time of writing, Magento 2 processes compound queries in the order they are defined.
|
|
1184
|
-
* We rely on this fact and only use the return of the last query.
|
|
1185
|
-
* This helps us keep query complexity down and save some server CPU cycles.
|
|
1186
|
-
* Driver behavior is not guaranteed if Magento no longer processes compound queries in the order they are defined.
|
|
1187
|
-
*/
|
|
1188
|
-
const updateAddressWithEmail = (extraCartFragments = []) => gql `
|
|
1189
|
-
mutation MagentoUpdateAddressWithEmail($cartId: String!, $email: String!, $address: CartAddressInput, $addressId: Int) {
|
|
1190
|
-
setBillingAddressOnCart(input: {
|
|
1191
|
-
cart_id: $cartId
|
|
1192
|
-
billing_address: {
|
|
1193
|
-
address: $address,
|
|
1194
|
-
customer_address_id: $addressId
|
|
1195
|
-
}
|
|
1196
|
-
}) {
|
|
1197
|
-
cart {
|
|
1198
|
-
id
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
setShippingAddressesOnCart(input: {
|
|
1202
|
-
cart_id: $cartId
|
|
1203
|
-
shipping_addresses: [{
|
|
1204
|
-
address: $address,
|
|
1205
|
-
customer_address_id: $addressId
|
|
1206
|
-
}]
|
|
1207
|
-
}) {
|
|
1208
|
-
cart {
|
|
1209
|
-
id
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
setGuestEmailOnCart(input: {
|
|
1213
|
-
cart_id: $cartId,
|
|
1214
|
-
email: $email
|
|
1215
|
-
}) {
|
|
1216
|
-
cart {
|
|
1217
|
-
...cart
|
|
1218
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
${cartFragment}
|
|
1223
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1224
|
-
`;
|
|
1225
|
-
|
|
1226
|
-
/**
|
|
1227
|
-
* Update the shipping and billing address of the cart.
|
|
1228
|
-
* At the time of writing, Magento 2 processes compound queries in the order they are defined.
|
|
1229
|
-
* We rely on this fact and only use the return of the last query.
|
|
1230
|
-
* This helps us keep query complexity down and save some server CPU cycles.
|
|
1231
|
-
* Driver behavior is not guaranteed if Magento no longer processes compound queries in the order they are defined.
|
|
1232
|
-
*/
|
|
1233
|
-
const updateAddress = (extraCartFragments = []) => gql `
|
|
1234
|
-
mutation MagentoUpdateAddress($cartId: String!, $address: CartAddressInput, $addressId: Int) {
|
|
1235
|
-
setBillingAddressOnCart(input: {
|
|
1236
|
-
cart_id: $cartId
|
|
1237
|
-
billing_address: {
|
|
1238
|
-
address: $address,
|
|
1239
|
-
customer_address_id: $addressId
|
|
1240
|
-
}
|
|
1241
|
-
}) {
|
|
1242
|
-
cart {
|
|
1243
|
-
id
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
setShippingAddressesOnCart(input: {
|
|
1247
|
-
cart_id: $cartId
|
|
1248
|
-
shipping_addresses: [{
|
|
1249
|
-
address: $address,
|
|
1250
|
-
customer_address_id: $addressId
|
|
1251
|
-
}]
|
|
1252
|
-
}) {
|
|
1253
|
-
cart {
|
|
1254
|
-
...cart
|
|
1255
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
${cartFragment}
|
|
1260
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1261
|
-
`;
|
|
1262
|
-
|
|
1263
|
-
const updateBillingAddressWithEmail = (extraCartFragments = []) => gql `
|
|
1264
|
-
mutation MagentoUpdateBillingAddressWithEmail(
|
|
1265
|
-
$cartId: String!,
|
|
1266
|
-
$address: BillingAddressInput!,
|
|
1267
|
-
$email: String!
|
|
1268
|
-
) {
|
|
1269
|
-
setBillingAddressOnCart(input: {
|
|
1270
|
-
cart_id: $cartId
|
|
1271
|
-
billing_address: $address
|
|
1272
|
-
}) {
|
|
1273
|
-
cart {
|
|
1274
|
-
...cart
|
|
1275
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
setGuestEmailOnCart(input: {
|
|
1279
|
-
cart_id: $cartId,
|
|
1280
|
-
email: $email
|
|
1281
|
-
}) {
|
|
1282
|
-
cart {
|
|
1283
|
-
email
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
${cartFragment}
|
|
1288
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1289
|
-
`;
|
|
1290
|
-
|
|
1291
|
-
const updateBillingAddress = (extraCartFragments = []) => gql `
|
|
1292
|
-
mutation MagentoUpdateBillingAddress(
|
|
1293
|
-
$cartId: String!,
|
|
1294
|
-
$address: BillingAddressInput!
|
|
1295
|
-
) {
|
|
1296
|
-
setBillingAddressOnCart(input: {
|
|
1297
|
-
cart_id: $cartId
|
|
1298
|
-
billing_address: $address
|
|
1299
|
-
}) {
|
|
1300
|
-
cart {
|
|
1301
|
-
...cart
|
|
1302
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
${cartFragment}
|
|
1307
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1308
|
-
`;
|
|
1309
|
-
|
|
1310
|
-
const updateCartItem = (extraCartFragments = []) => gql `
|
|
1311
|
-
mutation MagentoUpdateCartItem($cartId: String!, $input: CartItemUpdateInput!) {
|
|
1312
|
-
updateCartItems(input: {
|
|
1313
|
-
cart_id: $cartId
|
|
1314
|
-
cart_items: [$input]
|
|
1315
|
-
}) {
|
|
1316
|
-
cart {
|
|
1317
|
-
...cart
|
|
1318
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
${cartFragment}
|
|
1323
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1324
|
-
`;
|
|
1325
|
-
|
|
1326
|
-
const updateShippingAddressWithEmail = (extraCartFragments = []) => gql `
|
|
1327
|
-
mutation MagentoUpdateShippingAddressWithEmail(
|
|
1328
|
-
$cartId: String!,
|
|
1329
|
-
$address: ShippingAddressInput!,
|
|
1330
|
-
$email: String!
|
|
1331
|
-
) {
|
|
1332
|
-
setShippingAddressesOnCart(input: {
|
|
1333
|
-
cart_id: $cartId
|
|
1334
|
-
shipping_addresses: [$address]
|
|
1335
|
-
}) {
|
|
1336
|
-
cart {
|
|
1337
|
-
...cart
|
|
1338
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
setGuestEmailOnCart(input: {
|
|
1342
|
-
cart_id: $cartId,
|
|
1343
|
-
email: $email
|
|
1344
|
-
}) {
|
|
1345
|
-
cart {
|
|
1346
|
-
email
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
${cartFragment}
|
|
1351
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1352
|
-
`;
|
|
1353
|
-
|
|
1354
|
-
const updateShippingAddress = (extraCartFragments = []) => gql `
|
|
1355
|
-
mutation MagentoUpdateShippingAddress(
|
|
1356
|
-
$cartId: String!,
|
|
1357
|
-
$address: ShippingAddressInput!
|
|
1358
|
-
) {
|
|
1359
|
-
setShippingAddressesOnCart(input: {
|
|
1360
|
-
cart_id: $cartId
|
|
1361
|
-
shipping_addresses: [$address]
|
|
1362
|
-
}) {
|
|
1363
|
-
cart {
|
|
1364
|
-
...cart
|
|
1365
|
-
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
${cartFragment}
|
|
1370
|
-
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1371
|
-
`;
|
|
1372
|
-
|
|
1373
|
-
// TODO: move to @daffodil/driver/magento
|
|
1374
|
-
var MagentoCartGraphQlErrorCode;
|
|
1375
|
-
(function (MagentoCartGraphQlErrorCode) {
|
|
1376
|
-
MagentoCartGraphQlErrorCode["CART_NOT_FOUND"] = "graphql-no-such-entity";
|
|
1377
|
-
MagentoCartGraphQlErrorCode["BAD_INPUT"] = "graphql-input";
|
|
1378
|
-
MagentoCartGraphQlErrorCode["AUTHORIZATION"] = "graphql-authorization";
|
|
1379
|
-
})(MagentoCartGraphQlErrorCode || (MagentoCartGraphQlErrorCode = {}));
|
|
1380
|
-
|
|
1381
|
-
const DaffCartMagentoErrorMap = {
|
|
1382
|
-
[MagentoCartGraphQlErrorCode.CART_NOT_FOUND]: DaffCartNotFoundError,
|
|
1383
|
-
[MagentoCartGraphQlErrorCode.BAD_INPUT]: DaffBadInputError,
|
|
1384
|
-
[MagentoCartGraphQlErrorCode.AUTHORIZATION]: DaffUnauthorizedForCartError,
|
|
1385
|
-
};
|
|
1386
|
-
const DaffCartMagentoErrorMessageRegexMap = {
|
|
1387
|
-
[DaffCartDriverErrorCodes.INVALID_COUPON_CODE]: /The coupon code isn't valid/,
|
|
1388
|
-
[DaffCartDriverErrorCodes.PRODUCT_INSUFFICIENT_STOCK]: /The requested qty is not available/,
|
|
1389
|
-
[DaffCartDriverErrorCodes.PRODUCT_OUT_OF_STOCK]: /(This product is out of stock)|(Some of the products are out of stock)|(There are no source items with the in stock status)/,
|
|
1390
|
-
[DaffCartDriverErrorCodes.ITEM_EXCEEDS_MAX_QTY]: /The requested qty exceeds the maximum qty allowed in shopping cart/,
|
|
1391
|
-
[DaffCartDriverErrorCodes.INVALID_EMAIL]: /Invalid email format/,
|
|
1392
|
-
[DaffCartDriverErrorCodes.CART_NOT_FOUND]: /Could not find a cart with ID/,
|
|
1393
|
-
[DaffCartDriverErrorCodes.UNAUTHORIZED_FOR_CART]: /The current customer isn't authorized/,
|
|
1394
|
-
};
|
|
1395
|
-
const DaffCartMagentoUserErrorMap = {
|
|
1396
|
-
[MagentoCartUserInputErrorType.PRODUCT_NOT_FOUND]: DaffProductNotFoundError,
|
|
1397
|
-
[MagentoCartUserInputErrorType.INSUFFICIENT_STOCK]: DaffProductInsufficientStockError,
|
|
1398
|
-
[MagentoCartUserInputErrorType.NOT_SALABLE]: DaffProductOutOfStockError,
|
|
1399
|
-
[MagentoCartUserInputErrorType.UNDEFINED]: DaffCartInvalidAPIResponseError,
|
|
1400
|
-
};
|
|
1401
|
-
|
|
1402
|
-
/**
|
|
1403
|
-
* Transforms a single GraphQL error.
|
|
1404
|
-
* Optionally accepts a request payload which can be used in certain cases
|
|
1405
|
-
* to add supplemental info to the error.
|
|
1406
|
-
*/
|
|
1407
|
-
function transformMagentoCartGraphQlError(error, requestPayload) {
|
|
1408
|
-
// TODO: readdress this when we move to eslint
|
|
1409
|
-
// eslint-disable-next-line
|
|
1410
|
-
for (const code in DaffCartMagentoErrorMessageRegexMap) {
|
|
1411
|
-
const matchIndex = error.message.search(DaffCartMagentoErrorMessageRegexMap[code]);
|
|
1412
|
-
if (matchIndex > -1 && DaffCartDriverErrorMap[code]) {
|
|
1413
|
-
const errObj = new DaffCartDriverErrorMap[code](error.message);
|
|
1414
|
-
if (errObj instanceof DaffInvalidCouponCodeError) {
|
|
1415
|
-
errObj.coupon = requestPayload?.code;
|
|
1416
|
-
}
|
|
1417
|
-
return errObj;
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
return daffMagentoTransformGraphQlError(error, DaffCartMagentoErrorMap);
|
|
1421
|
-
}
|
|
1422
|
-
/**
|
|
1423
|
-
* Transforms only the first GraphQL error with the cart magento error transformer,
|
|
1424
|
-
* otherwise falls back to a standard Magento error transform.
|
|
1425
|
-
*/
|
|
1426
|
-
function transformCartMagentoError(error, requestPayload) {
|
|
1427
|
-
if (CombinedGraphQLErrors.is(error)) {
|
|
1428
|
-
return transformMagentoCartGraphQlError(error.errors[0], requestPayload);
|
|
1429
|
-
}
|
|
1430
|
-
else {
|
|
1431
|
-
return daffTransformMagentoError(error, DaffCartMagentoErrorMap);
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
function magentoCartTransformUserError(error) {
|
|
1435
|
-
return new (DaffCartMagentoUserErrorMap[error.code] || DaffCartInvalidAPIResponseError)(error.message);
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
const { token: DAFF_MAGENTO_CART_MUTATION_QUEUE,
|
|
1439
|
-
/**
|
|
1440
|
-
* Provider function for {@link DAFF_MAGENTO_CART_MUTATION_QUEUE}.
|
|
1441
|
-
*/
|
|
1442
|
-
provider: provideDaffCartMagentoMutationQueue, } = createSingleInjectionToken('DAFF_MAGENTO_CART_MUTATION_QUEUE', {
|
|
1443
|
-
providedIn: 'root',
|
|
1444
|
-
factory: () => new DaffQueuedApollo(inject(Apollo)),
|
|
1445
|
-
});
|
|
1446
|
-
|
|
1447
|
-
const DAFF_MAGENTO_GET_RECOVERABLE_ERRORS = [
|
|
1448
|
-
DaffProductOutOfStockError,
|
|
1449
|
-
];
|
|
1450
|
-
/**
|
|
1451
|
-
* A service for making Magento GraphQL queries for carts.
|
|
1452
|
-
*
|
|
1453
|
-
* @inheritdoc
|
|
1454
|
-
*/
|
|
1455
|
-
class DaffMagentoCartService {
|
|
1456
|
-
constructor(apollo, mutationQueue, cartTransformer, cartItemDriver, extraCartFragments) {
|
|
1457
|
-
this.apollo = apollo;
|
|
1458
|
-
this.mutationQueue = mutationQueue;
|
|
1459
|
-
this.cartTransformer = cartTransformer;
|
|
1460
|
-
this.cartItemDriver = cartItemDriver;
|
|
1461
|
-
this.extraCartFragments = extraCartFragments;
|
|
1462
|
-
}
|
|
1463
|
-
get(cartId) {
|
|
1464
|
-
return this.apollo.query({
|
|
1465
|
-
fetchPolicy: 'network-only',
|
|
1466
|
-
query: getCart(this.extraCartFragments),
|
|
1467
|
-
variables: { cartId },
|
|
1468
|
-
errorPolicy: 'all',
|
|
1469
|
-
}).pipe(map(({ data, error }) => ({
|
|
1470
|
-
response: data ? this.cartTransformer.transform(data.cart) : undefined,
|
|
1471
|
-
errors: CombinedGraphQLErrors.is(error)
|
|
1472
|
-
? error.errors?.map(e => {
|
|
1473
|
-
const err = transformMagentoCartGraphQlError(e);
|
|
1474
|
-
if (DAFF_MAGENTO_GET_RECOVERABLE_ERRORS.filter(klass => err instanceof klass).length > 0) {
|
|
1475
|
-
err.recoverable = true;
|
|
1476
|
-
}
|
|
1477
|
-
return err;
|
|
1478
|
-
}) || []
|
|
1479
|
-
: error ? [transformMagentoCartGraphQlError(error)] : [],
|
|
1480
|
-
})), switchMap((resp) => resp.errors.reduce((acc, err) => acc && err.recoverable, true)
|
|
1481
|
-
? of(resp)
|
|
1482
|
-
: throwError(() => resp.errors.filter((err) => !err.recoverable)[0])));
|
|
1483
|
-
}
|
|
1484
|
-
create() {
|
|
1485
|
-
return this.mutationQueue.mutate({ mutation: createCart }).pipe(map(result => ({ id: result.data.createEmptyCart })), catchError(err => throwError(() => transformCartMagentoError(err))));
|
|
1486
|
-
}
|
|
1487
|
-
addToCart(productId, qty) {
|
|
1488
|
-
throw new Error('Method is deprecated. Use DaffCartItemServiceInterface#add instead.');
|
|
1489
|
-
}
|
|
1490
|
-
clear(cartId) {
|
|
1491
|
-
return this.cartItemDriver.list(cartId).pipe(switchMap(items => forkJoin(...items.map(item => this.cartItemDriver.delete(cartId, item.id)))), switchMap(() => this.get(cartId)), map(({ response }) => response));
|
|
1492
|
-
}
|
|
1493
|
-
merge(guestCart, customerCart) {
|
|
1494
|
-
return this.mutationQueue.mutate({
|
|
1495
|
-
mutation: magentoMergeCartsMutation(this.extraCartFragments),
|
|
1496
|
-
variables: {
|
|
1497
|
-
source: guestCart,
|
|
1498
|
-
destination: customerCart,
|
|
1499
|
-
},
|
|
1500
|
-
errorPolicy: 'all',
|
|
1501
|
-
fetchPolicy: 'network-only',
|
|
1502
|
-
}).pipe(map(({ data, error }) => ({
|
|
1503
|
-
response: data ? this.cartTransformer.transform(data.mergeCarts) : undefined,
|
|
1504
|
-
errors: CombinedGraphQLErrors.is(error)
|
|
1505
|
-
? error.errors?.map(e => {
|
|
1506
|
-
const err = transformMagentoCartGraphQlError(e);
|
|
1507
|
-
if (DAFF_MAGENTO_GET_RECOVERABLE_ERRORS.filter(klass => err instanceof klass).length > 0) {
|
|
1508
|
-
err.recoverable = true;
|
|
1509
|
-
}
|
|
1510
|
-
return err;
|
|
1511
|
-
}) || []
|
|
1512
|
-
: error ? [transformMagentoCartGraphQlError(error)] : [],
|
|
1513
|
-
})), switchMap((resp) => resp.errors.reduce((acc, err) => acc && err.recoverable, true)
|
|
1514
|
-
? of(resp)
|
|
1515
|
-
: throwError(() => resp.errors.filter((err) => !err.recoverable)[0])));
|
|
1516
|
-
}
|
|
1517
|
-
;
|
|
1518
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartService, deps: [{ token: i1.Apollo }, { token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DaffMagentoCartTransformer }, { token: DaffCartItemDriver }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1519
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartService, providedIn: 'root' }); }
|
|
1520
|
-
}
|
|
1521
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartService, decorators: [{
|
|
1522
|
-
type: Injectable,
|
|
1523
|
-
args: [{
|
|
1524
|
-
providedIn: 'root',
|
|
1525
|
-
}]
|
|
1526
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: i5.DaffQueuedApollo, decorators: [{
|
|
1527
|
-
type: Inject,
|
|
1528
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
1529
|
-
}] }, { type: DaffMagentoCartTransformer }, { type: undefined, decorators: [{
|
|
1530
|
-
type: Inject,
|
|
1531
|
-
args: [DaffCartItemDriver]
|
|
1532
|
-
}] }, { type: undefined, decorators: [{
|
|
1533
|
-
type: Inject,
|
|
1534
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
1535
|
-
}] }] });
|
|
1536
|
-
|
|
1537
|
-
function transformSimpleCartItem(item) {
|
|
1538
|
-
return {
|
|
1539
|
-
quantity: item.qty,
|
|
1540
|
-
sku: item.productId,
|
|
1541
|
-
};
|
|
1542
|
-
}
|
|
1543
|
-
function transformCompositeCartItem(item) {
|
|
1544
|
-
return {
|
|
1545
|
-
...transformSimpleCartItem(item),
|
|
1546
|
-
selected_options: item.options?.map(option => option.value) || [],
|
|
1547
|
-
};
|
|
1548
|
-
}
|
|
1549
|
-
function transformConfigurableCartItem(item) {
|
|
1550
|
-
return {
|
|
1551
|
-
parent_sku: item.productId,
|
|
1552
|
-
quantity: item.qty,
|
|
1553
|
-
sku: item.variantId,
|
|
1554
|
-
};
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
/**
|
|
1558
|
-
* A service for making Magento GraphQL queries for carts.
|
|
1559
|
-
*
|
|
1560
|
-
* @inheritdoc
|
|
1561
|
-
*/
|
|
1562
|
-
class DaffMagentoCartItemService {
|
|
1563
|
-
constructor(apollo, mutationQueue, extraCartFragments, cartItemTransforms, cartTransformer, cartItemUpdateInputTransformer) {
|
|
1564
|
-
this.apollo = apollo;
|
|
1565
|
-
this.mutationQueue = mutationQueue;
|
|
1566
|
-
this.extraCartFragments = extraCartFragments;
|
|
1567
|
-
this.cartItemTransforms = cartItemTransforms;
|
|
1568
|
-
this.cartTransformer = cartTransformer;
|
|
1569
|
-
this.cartItemUpdateInputTransformer = cartItemUpdateInputTransformer;
|
|
1570
|
-
}
|
|
1571
|
-
list(cartId) {
|
|
1572
|
-
return this.apollo.query({
|
|
1573
|
-
query: listCartItems(this.extraCartFragments),
|
|
1574
|
-
variables: { cartId },
|
|
1575
|
-
fetchPolicy: 'network-only',
|
|
1576
|
-
}).pipe(map(result => result.data.cart.items.filter(item => !!item)), map(items => items.map(item => transformMagentoCartItem(daffTransformMagentoCartItem(item), item, this.cartItemTransforms))), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1577
|
-
}
|
|
1578
|
-
get(cartId, itemId) {
|
|
1579
|
-
return this.list(cartId).pipe(map(items => items.find(item => item.id === itemId)));
|
|
1580
|
-
}
|
|
1581
|
-
add(cartId, cartItemInput) {
|
|
1582
|
-
switch (cartItemInput.type) {
|
|
1583
|
-
case (DaffCartItemInputType.Composite):
|
|
1584
|
-
return this.addBundledProduct(cartId, cartItemInput);
|
|
1585
|
-
case (DaffCartItemInputType.Configurable):
|
|
1586
|
-
return this.addConfigurableProduct(cartId, cartItemInput);
|
|
1587
|
-
default:
|
|
1588
|
-
return this.addSimpleProduct(cartId, cartItemInput);
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
update(cartId, itemId, changes) {
|
|
1592
|
-
return this.mutationQueue.mutate({
|
|
1593
|
-
mutation: updateCartItem(this.extraCartFragments),
|
|
1594
|
-
variables: {
|
|
1595
|
-
cartId,
|
|
1596
|
-
input: this.cartItemUpdateInputTransformer.transform({
|
|
1597
|
-
...changes,
|
|
1598
|
-
id: itemId,
|
|
1599
|
-
}),
|
|
1600
|
-
},
|
|
1601
|
-
fetchPolicy: 'network-only',
|
|
1602
|
-
}).pipe(map(result => this.cartTransformer.transform(result.data.updateCartItems.cart)), catchError(err => throwError(() => transformCartMagentoError(err))));
|
|
1603
|
-
}
|
|
1604
|
-
delete(cartId, itemId) {
|
|
1605
|
-
return this.mutationQueue.mutate({
|
|
1606
|
-
mutation: removeCartItem(this.extraCartFragments),
|
|
1607
|
-
variables: {
|
|
1608
|
-
cartId,
|
|
1609
|
-
itemId,
|
|
1610
|
-
},
|
|
1611
|
-
fetchPolicy: 'network-only',
|
|
1612
|
-
}).pipe(map(result => this.cartTransformer.transform(result.data.removeItemFromCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1613
|
-
}
|
|
1614
|
-
addBundledProduct(cartId, cartItemInput) {
|
|
1615
|
-
return this.addCartItemRequest(cartId, transformCompositeCartItem(cartItemInput));
|
|
1616
|
-
}
|
|
1617
|
-
addConfigurableProduct(cartId, cartItemInput) {
|
|
1618
|
-
return this.addCartItemRequest(cartId, transformConfigurableCartItem(cartItemInput));
|
|
1619
|
-
}
|
|
1620
|
-
addSimpleProduct(cartId, cartItemInput) {
|
|
1621
|
-
return this.addCartItemRequest(cartId, transformSimpleCartItem(cartItemInput));
|
|
1622
|
-
}
|
|
1623
|
-
addCartItemRequest(cartId, input) {
|
|
1624
|
-
return this.mutationQueue.mutate({
|
|
1625
|
-
mutation: addCartItem(this.extraCartFragments),
|
|
1626
|
-
variables: {
|
|
1627
|
-
cartId,
|
|
1628
|
-
input,
|
|
1629
|
-
},
|
|
1630
|
-
fetchPolicy: 'network-only',
|
|
1631
|
-
}).pipe(switchMap((result) => result.data.addProductsToCart.user_errors.length > 0
|
|
1632
|
-
? throwError(() => magentoCartTransformUserError(result.data.addProductsToCart.user_errors[0]))
|
|
1633
|
-
: of(this.cartTransformer.transform(result.data.addProductsToCart.cart))), catchError(err => throwError(() => transformCartMagentoError(err))));
|
|
1634
|
-
}
|
|
1635
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartItemService, deps: [{ token: i1.Apollo }, { token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS }, { token: DaffMagentoCartTransformer }, { token: DaffMagentoCartItemUpdateInputTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1636
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartItemService, providedIn: 'root' }); }
|
|
1637
|
-
}
|
|
1638
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartItemService, decorators: [{
|
|
1639
|
-
type: Injectable,
|
|
1640
|
-
args: [{
|
|
1641
|
-
providedIn: 'root',
|
|
1642
|
-
}]
|
|
1643
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: i5.DaffQueuedApollo, decorators: [{
|
|
1644
|
-
type: Inject,
|
|
1645
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
1646
|
-
}] }, { type: undefined, decorators: [{
|
|
1647
|
-
type: Inject,
|
|
1648
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
1649
|
-
}] }, { type: undefined, decorators: [{
|
|
1650
|
-
type: Inject,
|
|
1651
|
-
args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS]
|
|
1652
|
-
}] }, { type: DaffMagentoCartTransformer }, { type: DaffMagentoCartItemUpdateInputTransformer }] });
|
|
1653
|
-
|
|
1654
|
-
/**
|
|
1655
|
-
* A service for making Magento GraphQL queries for carts.
|
|
1656
|
-
*
|
|
1657
|
-
* @inheritdoc
|
|
1658
|
-
*/
|
|
1659
|
-
class DaffMagentoCartPaymentService {
|
|
1660
|
-
constructor(apollo, mutationQueue, cartTransformer, paymentTransformer, paymentInputTransformer, cartAddressInputTransformer, extraCartFragments) {
|
|
1661
|
-
this.apollo = apollo;
|
|
1662
|
-
this.mutationQueue = mutationQueue;
|
|
1663
|
-
this.cartTransformer = cartTransformer;
|
|
1664
|
-
this.paymentTransformer = paymentTransformer;
|
|
1665
|
-
this.paymentInputTransformer = paymentInputTransformer;
|
|
1666
|
-
this.cartAddressInputTransformer = cartAddressInputTransformer;
|
|
1667
|
-
this.extraCartFragments = extraCartFragments;
|
|
1668
|
-
}
|
|
1669
|
-
get(cartId) {
|
|
1670
|
-
return this.apollo.query({
|
|
1671
|
-
query: getSelectedPaymentMethod(this.extraCartFragments),
|
|
1672
|
-
variables: { cartId },
|
|
1673
|
-
fetchPolicy: 'network-only',
|
|
1674
|
-
}).pipe(map(result => this.paymentTransformer.transform(result.data.cart.selected_payment_method)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1675
|
-
}
|
|
1676
|
-
update(cartId, payment, billingAddress) {
|
|
1677
|
-
return billingAddress
|
|
1678
|
-
? this.updateWithBilling(cartId, payment, billingAddress)
|
|
1679
|
-
: this.mutationQueue.mutate({
|
|
1680
|
-
mutation: setSelectedPaymentMethod(this.extraCartFragments),
|
|
1681
|
-
variables: {
|
|
1682
|
-
cartId,
|
|
1683
|
-
payment: this.paymentInputTransformer.transform(payment),
|
|
1684
|
-
},
|
|
1685
|
-
fetchPolicy: 'network-only',
|
|
1686
|
-
}).pipe(map(result => this.cartTransformer.transform(result.data.setPaymentMethodOnCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1687
|
-
}
|
|
1688
|
-
updateWithBilling(cartId, payment, address) {
|
|
1689
|
-
return address.email
|
|
1690
|
-
? this.updateWithBillingAddressAndEmail(cartId, payment, address)
|
|
1691
|
-
: this.updateWithBillingAddress(cartId, payment, address);
|
|
1692
|
-
}
|
|
1693
|
-
remove(cartId) {
|
|
1694
|
-
return this.mutationQueue.mutate({
|
|
1695
|
-
mutation: setSelectedPaymentMethod(this.extraCartFragments),
|
|
1696
|
-
variables: {
|
|
1697
|
-
cartId,
|
|
1698
|
-
payment: { code: '' },
|
|
1699
|
-
},
|
|
1700
|
-
fetchPolicy: 'network-only',
|
|
1701
|
-
}).pipe(map(() => undefined), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1702
|
-
}
|
|
1703
|
-
updateWithBillingAddress(cartId, payment, address) {
|
|
1704
|
-
return this.mutationQueue.mutate({
|
|
1705
|
-
mutation: setSelectedPaymentMethodWithBilling(this.extraCartFragments),
|
|
1706
|
-
variables: {
|
|
1707
|
-
cartId,
|
|
1708
|
-
payment: this.paymentInputTransformer.transform(payment),
|
|
1709
|
-
address: this.cartAddressInputTransformer.transform(address),
|
|
1710
|
-
},
|
|
1711
|
-
fetchPolicy: 'network-only',
|
|
1712
|
-
}).pipe(map(resp => this.cartTransformer.transform(resp.data.setPaymentMethodOnCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1713
|
-
}
|
|
1714
|
-
updateWithBillingAddressAndEmail(cartId, payment, address) {
|
|
1715
|
-
return this.mutationQueue.mutate({
|
|
1716
|
-
mutation: setSelectedPaymentMethodWithBillingAndEmail(this.extraCartFragments),
|
|
1717
|
-
variables: {
|
|
1718
|
-
cartId,
|
|
1719
|
-
email: address.email,
|
|
1720
|
-
payment: this.paymentInputTransformer.transform(payment),
|
|
1721
|
-
address: this.cartAddressInputTransformer.transform(address),
|
|
1722
|
-
},
|
|
1723
|
-
fetchPolicy: 'network-only',
|
|
1724
|
-
}).pipe(map(resp => this.cartTransformer.transform(resp.data.setGuestEmailOnCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1725
|
-
}
|
|
1726
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentService, deps: [{ token: i1.Apollo }, { token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DaffMagentoCartTransformer }, { token: DaffMagentoCartPaymentTransformer }, { token: DaffMagentoPaymentMethodInputTransformer }, { token: DaffMagentoBillingAddressInputTransformer }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1727
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentService, providedIn: 'root' }); }
|
|
1728
|
-
}
|
|
1729
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentService, decorators: [{
|
|
1730
|
-
type: Injectable,
|
|
1731
|
-
args: [{
|
|
1732
|
-
providedIn: 'root',
|
|
1733
|
-
}]
|
|
1734
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: i5.DaffQueuedApollo, decorators: [{
|
|
1735
|
-
type: Inject,
|
|
1736
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
1737
|
-
}] }, { type: DaffMagentoCartTransformer }, { type: DaffMagentoCartPaymentTransformer }, { type: DaffMagentoPaymentMethodInputTransformer }, { type: DaffMagentoBillingAddressInputTransformer }, { type: undefined, decorators: [{
|
|
1738
|
-
type: Inject,
|
|
1739
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
1740
|
-
}] }] });
|
|
1741
|
-
|
|
1742
|
-
/**
|
|
1743
|
-
* A service for making Magento GraphQL queries for carts.
|
|
1744
|
-
*
|
|
1745
|
-
* @inheritdoc
|
|
1746
|
-
*/
|
|
1747
|
-
class DaffMagentoCartPaymentMethodsService {
|
|
1748
|
-
constructor(apollo, extraCartFragments, paymentTransformer) {
|
|
1749
|
-
this.apollo = apollo;
|
|
1750
|
-
this.extraCartFragments = extraCartFragments;
|
|
1751
|
-
this.paymentTransformer = paymentTransformer;
|
|
1752
|
-
}
|
|
1753
|
-
list(cartId) {
|
|
1754
|
-
return this.apollo.query({
|
|
1755
|
-
query: listPaymentMethods(this.extraCartFragments),
|
|
1756
|
-
variables: { cartId },
|
|
1757
|
-
fetchPolicy: 'network-only',
|
|
1758
|
-
}).pipe(map(result => result.data.cart.available_payment_methods.map(item => this.paymentTransformer.transform(item))), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1759
|
-
}
|
|
1760
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentMethodsService, deps: [{ token: i1.Apollo }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DaffMagentoCartPaymentTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1761
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentMethodsService, providedIn: 'root' }); }
|
|
1762
|
-
}
|
|
1763
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartPaymentMethodsService, decorators: [{
|
|
1764
|
-
type: Injectable,
|
|
1765
|
-
args: [{
|
|
1766
|
-
providedIn: 'root',
|
|
1767
|
-
}]
|
|
1768
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: undefined, decorators: [{
|
|
1769
|
-
type: Inject,
|
|
1770
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
1771
|
-
}] }, { type: DaffMagentoCartPaymentTransformer }] });
|
|
1772
|
-
|
|
1773
|
-
/**
|
|
1774
|
-
* A service for making Magento GraphQL queries for carts.
|
|
1775
|
-
*
|
|
1776
|
-
* @inheritdoc
|
|
1777
|
-
*/
|
|
1778
|
-
class DaffMagentoCartAddressService {
|
|
1779
|
-
constructor(mutationQueue, extraCartFragments, cartTransformer, cartAddressInputTransformer) {
|
|
1780
|
-
this.mutationQueue = mutationQueue;
|
|
1781
|
-
this.extraCartFragments = extraCartFragments;
|
|
1782
|
-
this.cartTransformer = cartTransformer;
|
|
1783
|
-
this.cartAddressInputTransformer = cartAddressInputTransformer;
|
|
1784
|
-
}
|
|
1785
|
-
update(cartId, address) {
|
|
1786
|
-
return address.email ? this.updateAddressWithEmail(cartId, address) : this.updateAddress(cartId, address);
|
|
1787
|
-
}
|
|
1788
|
-
getAddressInput(address) {
|
|
1789
|
-
return address.id
|
|
1790
|
-
? {
|
|
1791
|
-
addressId: Number(address.id),
|
|
1792
|
-
}
|
|
1793
|
-
: {
|
|
1794
|
-
address: this.cartAddressInputTransformer.transform(address),
|
|
1795
|
-
};
|
|
1796
|
-
}
|
|
1797
|
-
updateAddress(cartId, address) {
|
|
1798
|
-
return this.mutationQueue.mutate({
|
|
1799
|
-
mutation: updateAddress(this.extraCartFragments),
|
|
1800
|
-
variables: {
|
|
1801
|
-
...this.getAddressInput(address),
|
|
1802
|
-
cartId,
|
|
1803
|
-
},
|
|
1804
|
-
fetchPolicy: 'network-only',
|
|
1805
|
-
}).pipe(map(resp => this.cartTransformer.transform(resp.data.setShippingAddressesOnCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1806
|
-
}
|
|
1807
|
-
updateAddressWithEmail(cartId, address) {
|
|
1808
|
-
return this.mutationQueue.mutate({
|
|
1809
|
-
mutation: updateAddressWithEmail(this.extraCartFragments),
|
|
1810
|
-
variables: {
|
|
1811
|
-
...this.getAddressInput(address),
|
|
1812
|
-
cartId,
|
|
1813
|
-
email: address.email,
|
|
1814
|
-
},
|
|
1815
|
-
fetchPolicy: 'network-only',
|
|
1816
|
-
}).pipe(map(resp => this.cartTransformer.transform(resp.data.setGuestEmailOnCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1817
|
-
}
|
|
1818
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressService, deps: [{ token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DaffMagentoCartTransformer }, { token: DaffMagentoCartAddressInputTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1819
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressService, providedIn: 'root' }); }
|
|
1820
|
-
}
|
|
1821
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartAddressService, decorators: [{
|
|
1822
|
-
type: Injectable,
|
|
1823
|
-
args: [{
|
|
1824
|
-
providedIn: 'root',
|
|
1825
|
-
}]
|
|
1826
|
-
}], ctorParameters: () => [{ type: i5.DaffQueuedApollo, decorators: [{
|
|
1827
|
-
type: Inject,
|
|
1828
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
1829
|
-
}] }, { type: undefined, decorators: [{
|
|
1830
|
-
type: Inject,
|
|
1831
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
1832
|
-
}] }, { type: DaffMagentoCartTransformer }, { type: DaffMagentoCartAddressInputTransformer }] });
|
|
1833
|
-
|
|
1834
|
-
/**
|
|
1835
|
-
* A service for making Magento GraphQL queries for carts.
|
|
1836
|
-
*
|
|
1837
|
-
* @inheritdoc
|
|
1838
|
-
*/
|
|
1839
|
-
class DaffMagentoCartBillingAddressService {
|
|
1840
|
-
constructor(apollo, mutationQueue, extraCartFragments, cartTransformer, billingAddressTransformer, billingAddressInputTransformer) {
|
|
1841
|
-
this.apollo = apollo;
|
|
1842
|
-
this.mutationQueue = mutationQueue;
|
|
1843
|
-
this.extraCartFragments = extraCartFragments;
|
|
1844
|
-
this.cartTransformer = cartTransformer;
|
|
1845
|
-
this.billingAddressTransformer = billingAddressTransformer;
|
|
1846
|
-
this.billingAddressInputTransformer = billingAddressInputTransformer;
|
|
1847
|
-
}
|
|
1848
|
-
get(cartId) {
|
|
1849
|
-
return this.apollo.query({
|
|
1850
|
-
query: getBillingAddress(this.extraCartFragments),
|
|
1851
|
-
variables: { cartId },
|
|
1852
|
-
fetchPolicy: 'network-only',
|
|
1853
|
-
}).pipe(map(result => result.data.cart.billing_address
|
|
1854
|
-
? this.billingAddressTransformer.transform({
|
|
1855
|
-
...result.data.cart.billing_address,
|
|
1856
|
-
email: result.data.cart.email,
|
|
1857
|
-
})
|
|
1858
|
-
: null), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1859
|
-
}
|
|
1860
|
-
update(cartId, address) {
|
|
1861
|
-
return address.email ? this.updateAddressWithEmail(cartId, address) : this.updateAddress(cartId, address);
|
|
1862
|
-
}
|
|
1863
|
-
updateAddress(cartId, address) {
|
|
1864
|
-
return this.mutationQueue.mutate({
|
|
1865
|
-
mutation: updateBillingAddress(this.extraCartFragments),
|
|
1866
|
-
variables: {
|
|
1867
|
-
cartId,
|
|
1868
|
-
address: this.billingAddressInputTransformer.transform(address),
|
|
1869
|
-
},
|
|
1870
|
-
fetchPolicy: 'network-only',
|
|
1871
|
-
}).pipe(map(resp => this.cartTransformer.transform(resp.data.setBillingAddressOnCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1872
|
-
}
|
|
1873
|
-
updateAddressWithEmail(cartId, address) {
|
|
1874
|
-
return this.mutationQueue.mutate({
|
|
1875
|
-
mutation: updateBillingAddressWithEmail(this.extraCartFragments),
|
|
1876
|
-
variables: {
|
|
1877
|
-
cartId,
|
|
1878
|
-
email: address.email,
|
|
1879
|
-
address: this.billingAddressInputTransformer.transform(address),
|
|
1880
|
-
},
|
|
1881
|
-
fetchPolicy: 'network-only',
|
|
1882
|
-
}).pipe(map(resp => this.cartTransformer.transform({
|
|
1883
|
-
...resp.data.setBillingAddressOnCart.cart,
|
|
1884
|
-
email: resp.data.setGuestEmailOnCart.cart.email,
|
|
1885
|
-
})), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1886
|
-
}
|
|
1887
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartBillingAddressService, deps: [{ token: i1.Apollo }, { token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DaffMagentoCartTransformer }, { token: DaffMagentoBillingAddressTransformer }, { token: DaffMagentoBillingAddressInputTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1888
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartBillingAddressService, providedIn: 'root' }); }
|
|
1889
|
-
}
|
|
1890
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartBillingAddressService, decorators: [{
|
|
1891
|
-
type: Injectable,
|
|
1892
|
-
args: [{
|
|
1893
|
-
providedIn: 'root',
|
|
1894
|
-
}]
|
|
1895
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: i5.DaffQueuedApollo, decorators: [{
|
|
1896
|
-
type: Inject,
|
|
1897
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
1898
|
-
}] }, { type: undefined, decorators: [{
|
|
1899
|
-
type: Inject,
|
|
1900
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
1901
|
-
}] }, { type: DaffMagentoCartTransformer }, { type: DaffMagentoBillingAddressTransformer }, { type: DaffMagentoBillingAddressInputTransformer }] });
|
|
1902
|
-
|
|
1903
|
-
/**
|
|
1904
|
-
* A service for making Magento GraphQL queries for a cart's shipping address.
|
|
1905
|
-
*
|
|
1906
|
-
* @inheritdoc
|
|
1907
|
-
*/
|
|
1908
|
-
class DaffMagentoCartShippingAddressService {
|
|
1909
|
-
constructor(apollo, mutationQueue, extraCartFragments, cartTransformer, shippingAddressTransformer, shippingAddressInputTransformer) {
|
|
1910
|
-
this.apollo = apollo;
|
|
1911
|
-
this.mutationQueue = mutationQueue;
|
|
1912
|
-
this.extraCartFragments = extraCartFragments;
|
|
1913
|
-
this.cartTransformer = cartTransformer;
|
|
1914
|
-
this.shippingAddressTransformer = shippingAddressTransformer;
|
|
1915
|
-
this.shippingAddressInputTransformer = shippingAddressInputTransformer;
|
|
1916
|
-
}
|
|
1917
|
-
get(cartId) {
|
|
1918
|
-
return this.apollo.query({
|
|
1919
|
-
query: getShippingAddress(this.extraCartFragments),
|
|
1920
|
-
variables: { cartId },
|
|
1921
|
-
fetchPolicy: 'network-only',
|
|
1922
|
-
}).pipe(map(result => result.data.cart.shipping_addresses[0]
|
|
1923
|
-
? this.shippingAddressTransformer.transform({
|
|
1924
|
-
...result.data.cart.shipping_addresses[0],
|
|
1925
|
-
email: result.data.cart.email,
|
|
1926
|
-
})
|
|
1927
|
-
: null), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1928
|
-
}
|
|
1929
|
-
update(cartId, address) {
|
|
1930
|
-
return address.email ? this.updateAddressWithEmail(cartId, address) : this.updateAddress(cartId, address);
|
|
1931
|
-
}
|
|
1932
|
-
updateAddress(cartId, address) {
|
|
1933
|
-
return this.mutationQueue.mutate({
|
|
1934
|
-
mutation: updateShippingAddress(this.extraCartFragments),
|
|
1935
|
-
variables: {
|
|
1936
|
-
cartId,
|
|
1937
|
-
address: this.shippingAddressInputTransformer.transform(address),
|
|
1938
|
-
},
|
|
1939
|
-
fetchPolicy: 'network-only',
|
|
1940
|
-
}).pipe(map(resp => this.cartTransformer.transform(resp.data.setShippingAddressesOnCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1941
|
-
}
|
|
1942
|
-
updateAddressWithEmail(cartId, address) {
|
|
1943
|
-
return this.mutationQueue.mutate({
|
|
1944
|
-
mutation: updateShippingAddressWithEmail(this.extraCartFragments),
|
|
1945
|
-
variables: {
|
|
1946
|
-
cartId,
|
|
1947
|
-
email: address.email,
|
|
1948
|
-
address: this.shippingAddressInputTransformer.transform(address),
|
|
1949
|
-
},
|
|
1950
|
-
fetchPolicy: 'network-only',
|
|
1951
|
-
}).pipe(map(resp => this.cartTransformer.transform({
|
|
1952
|
-
...resp.data.setShippingAddressesOnCart.cart,
|
|
1953
|
-
email: resp.data.setGuestEmailOnCart.cart.email,
|
|
1954
|
-
})), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1955
|
-
}
|
|
1956
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingAddressService, deps: [{ token: i1.Apollo }, { token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DaffMagentoCartTransformer }, { token: DaffMagentoShippingAddressTransformer }, { token: DaffMagentoShippingAddressInputTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1957
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingAddressService, providedIn: 'root' }); }
|
|
1958
|
-
}
|
|
1959
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingAddressService, decorators: [{
|
|
1960
|
-
type: Injectable,
|
|
1961
|
-
args: [{
|
|
1962
|
-
providedIn: 'root',
|
|
1963
|
-
}]
|
|
1964
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: i5.DaffQueuedApollo, decorators: [{
|
|
1965
|
-
type: Inject,
|
|
1966
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
1967
|
-
}] }, { type: undefined, decorators: [{
|
|
1968
|
-
type: Inject,
|
|
1969
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
1970
|
-
}] }, { type: DaffMagentoCartTransformer }, { type: DaffMagentoShippingAddressTransformer }, { type: DaffMagentoShippingAddressInputTransformer }] });
|
|
1971
|
-
|
|
1972
|
-
/**
|
|
1973
|
-
* A service for making Magento GraphQL queries for carts' shipping methods.
|
|
1974
|
-
*
|
|
1975
|
-
* @inheritdoc
|
|
1976
|
-
*/
|
|
1977
|
-
class DaffMagentoCartShippingMethodsService {
|
|
1978
|
-
constructor(apollo, extraCartFragments, shippingRateTransformer) {
|
|
1979
|
-
this.apollo = apollo;
|
|
1980
|
-
this.extraCartFragments = extraCartFragments;
|
|
1981
|
-
this.shippingRateTransformer = shippingRateTransformer;
|
|
1982
|
-
}
|
|
1983
|
-
list(cartId) {
|
|
1984
|
-
return this.apollo.query({
|
|
1985
|
-
query: listShippingMethods(this.extraCartFragments),
|
|
1986
|
-
variables: { cartId },
|
|
1987
|
-
fetchPolicy: 'network-only',
|
|
1988
|
-
}).pipe(map(result => result.data.cart.shipping_addresses[0].available_shipping_methods.map(item => this.shippingRateTransformer.transform(item))), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
1989
|
-
}
|
|
1990
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingMethodsService, deps: [{ token: i1.Apollo }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DaffMagentoCartShippingRateTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1991
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingMethodsService, providedIn: 'root' }); }
|
|
1992
|
-
}
|
|
1993
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingMethodsService, decorators: [{
|
|
1994
|
-
type: Injectable,
|
|
1995
|
-
args: [{
|
|
1996
|
-
providedIn: 'root',
|
|
1997
|
-
}]
|
|
1998
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: undefined, decorators: [{
|
|
1999
|
-
type: Inject,
|
|
2000
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
2001
|
-
}] }, { type: DaffMagentoCartShippingRateTransformer }] });
|
|
2002
|
-
|
|
2003
|
-
/**
|
|
2004
|
-
* A service for making Magento GraphQL queries for carts.
|
|
2005
|
-
*
|
|
2006
|
-
* @inheritdoc
|
|
2007
|
-
*/
|
|
2008
|
-
class DaffMagentoCartShippingInformationService {
|
|
2009
|
-
constructor(apollo, mutationQueue, extraCartFragments, cartTransformer, shippingRateTransformer, shippingMethodInputTransformer) {
|
|
2010
|
-
this.apollo = apollo;
|
|
2011
|
-
this.mutationQueue = mutationQueue;
|
|
2012
|
-
this.extraCartFragments = extraCartFragments;
|
|
2013
|
-
this.cartTransformer = cartTransformer;
|
|
2014
|
-
this.shippingRateTransformer = shippingRateTransformer;
|
|
2015
|
-
this.shippingMethodInputTransformer = shippingMethodInputTransformer;
|
|
2016
|
-
}
|
|
2017
|
-
get(cartId) {
|
|
2018
|
-
return this.apollo.query({
|
|
2019
|
-
query: getSelectedShippingMethod(this.extraCartFragments),
|
|
2020
|
-
variables: { cartId },
|
|
2021
|
-
fetchPolicy: 'network-only',
|
|
2022
|
-
}).pipe(map(result => result.data.cart.shipping_addresses[0]
|
|
2023
|
-
? this.shippingRateTransformer.transform(result.data.cart.shipping_addresses[0].selected_shipping_method)
|
|
2024
|
-
: null), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
2025
|
-
}
|
|
2026
|
-
update(cartId, shippingInfo) {
|
|
2027
|
-
return this.mutationQueue.mutate({
|
|
2028
|
-
mutation: setSelectedShippingMethod(this.extraCartFragments),
|
|
2029
|
-
variables: {
|
|
2030
|
-
cartId,
|
|
2031
|
-
method: this.shippingMethodInputTransformer.transform(shippingInfo),
|
|
2032
|
-
},
|
|
2033
|
-
fetchPolicy: 'network-only',
|
|
2034
|
-
}).pipe(switchMap(result =>
|
|
2035
|
-
// because Magento only returns the selected shipping method for the mutation
|
|
2036
|
-
// we have to manually refetch the available shipping methods
|
|
2037
|
-
// with fetchPolicy: 'network-only' in order to skip the cache
|
|
2038
|
-
this.apollo.query({
|
|
2039
|
-
query: listShippingMethods(this.extraCartFragments),
|
|
2040
|
-
variables: { cartId },
|
|
2041
|
-
fetchPolicy: 'network-only',
|
|
2042
|
-
}).pipe(map(shippingMethods => ({
|
|
2043
|
-
...this.cartTransformer.transform(result.data.setShippingMethodsOnCart.cart),
|
|
2044
|
-
available_shipping_methods: shippingMethods.data.cart.shipping_addresses[0].available_shipping_methods.map(item => this.shippingRateTransformer.transform(item)),
|
|
2045
|
-
})))), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
2046
|
-
}
|
|
2047
|
-
delete(cartId, id) {
|
|
2048
|
-
return this.mutationQueue.mutate({
|
|
2049
|
-
mutation: setSelectedShippingMethod(this.extraCartFragments),
|
|
2050
|
-
variables: {
|
|
2051
|
-
cartId,
|
|
2052
|
-
method: {
|
|
2053
|
-
carrier_code: '',
|
|
2054
|
-
method_code: '',
|
|
2055
|
-
},
|
|
2056
|
-
},
|
|
2057
|
-
}).pipe(map(result => this.cartTransformer.transform(result.data.setShippingMethodsOnCart.cart)), catchError(error => throwError(() => transformCartMagentoError(error))));
|
|
2058
|
-
}
|
|
2059
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingInformationService, deps: [{ token: i1.Apollo }, { token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DaffMagentoCartTransformer }, { token: DaffMagentoCartShippingRateTransformer }, { token: DaffMagentoShippingMethodInputTransformer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2060
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingInformationService, providedIn: 'root' }); }
|
|
2061
|
-
}
|
|
2062
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartShippingInformationService, decorators: [{
|
|
2063
|
-
type: Injectable,
|
|
2064
|
-
args: [{
|
|
2065
|
-
providedIn: 'root',
|
|
2066
|
-
}]
|
|
2067
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: i5.DaffQueuedApollo, decorators: [{
|
|
2068
|
-
type: Inject,
|
|
2069
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
2070
|
-
}] }, { type: undefined, decorators: [{
|
|
2071
|
-
type: Inject,
|
|
2072
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
2073
|
-
}] }, { type: DaffMagentoCartTransformer }, { type: DaffMagentoCartShippingRateTransformer }, { type: DaffMagentoShippingMethodInputTransformer }] });
|
|
2074
|
-
|
|
2075
|
-
/**
|
|
2076
|
-
* A service for making Magento GraphQL queries for carts.
|
|
2077
|
-
*
|
|
2078
|
-
* @inheritdoc
|
|
2079
|
-
*/
|
|
2080
|
-
class DaffMagentoCartCouponService {
|
|
2081
|
-
constructor(mutationQueue, extraCartFragments, cartTransformer, apollo) {
|
|
2082
|
-
this.mutationQueue = mutationQueue;
|
|
2083
|
-
this.extraCartFragments = extraCartFragments;
|
|
2084
|
-
this.cartTransformer = cartTransformer;
|
|
2085
|
-
this.apollo = apollo;
|
|
2086
|
-
}
|
|
2087
|
-
apply(cartId, coupon) {
|
|
2088
|
-
return this.mutationQueue.mutate({
|
|
2089
|
-
mutation: applyCoupon(this.extraCartFragments),
|
|
2090
|
-
variables: {
|
|
2091
|
-
cartId,
|
|
2092
|
-
couponCode: coupon.code,
|
|
2093
|
-
},
|
|
2094
|
-
fetchPolicy: 'network-only',
|
|
2095
|
-
}).pipe(map(result => this.cartTransformer.transform(result.data.applyCouponToCart.cart)), catchError(err => throwError(() => transformCartMagentoError(err, coupon))));
|
|
2096
|
-
}
|
|
2097
|
-
list(cartId) {
|
|
2098
|
-
return this.apollo.query({
|
|
2099
|
-
query: listCartCoupons(this.extraCartFragments),
|
|
2100
|
-
variables: {
|
|
2101
|
-
cartId,
|
|
2102
|
-
},
|
|
2103
|
-
fetchPolicy: 'network-only',
|
|
2104
|
-
}).pipe(map(result => result.data.cart.applied_coupons.map(daffMagentoCouponTransform)), catchError(err => throwError(() => transformCartMagentoError(err))));
|
|
2105
|
-
}
|
|
2106
|
-
remove(cartId, coupon) {
|
|
2107
|
-
return this.removeAll(cartId);
|
|
2108
|
-
}
|
|
2109
|
-
removeAll(cartId) {
|
|
2110
|
-
return this.mutationQueue.mutate({
|
|
2111
|
-
mutation: removeAllCoupons(this.extraCartFragments),
|
|
2112
|
-
variables: {
|
|
2113
|
-
cartId,
|
|
2114
|
-
},
|
|
2115
|
-
fetchPolicy: 'network-only',
|
|
2116
|
-
}).pipe(map(result => this.cartTransformer.transform(result.data.removeCouponFromCart.cart)), catchError(err => throwError(() => transformCartMagentoError(err))));
|
|
2117
|
-
}
|
|
2118
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartCouponService, deps: [{ token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DaffMagentoCartTransformer }, { token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2119
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartCouponService, providedIn: 'root' }); }
|
|
2120
|
-
}
|
|
2121
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartCouponService, decorators: [{
|
|
2122
|
-
type: Injectable,
|
|
2123
|
-
args: [{
|
|
2124
|
-
providedIn: 'root',
|
|
2125
|
-
}]
|
|
2126
|
-
}], ctorParameters: () => [{ type: i5.DaffQueuedApollo, decorators: [{
|
|
2127
|
-
type: Inject,
|
|
2128
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
2129
|
-
}] }, { type: undefined, decorators: [{
|
|
2130
|
-
type: Inject,
|
|
2131
|
-
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
2132
|
-
}] }, { type: DaffMagentoCartTransformer }, { type: i1.Apollo }] });
|
|
2133
|
-
|
|
2134
|
-
/**
|
|
2135
|
-
* A service for making Magento GraphQL queries for carts.
|
|
2136
|
-
*
|
|
2137
|
-
* @inheritdoc
|
|
2138
|
-
*/
|
|
2139
|
-
class DaffMagentoCartOrderService {
|
|
2140
|
-
constructor(mutationQueue) {
|
|
2141
|
-
this.mutationQueue = mutationQueue;
|
|
2142
|
-
}
|
|
2143
|
-
placeOrder(cartId, payment) {
|
|
2144
|
-
return this.mutationQueue.mutate({
|
|
2145
|
-
mutation: placeOrder,
|
|
2146
|
-
variables: {
|
|
2147
|
-
cartId,
|
|
2148
|
-
},
|
|
2149
|
-
fetchPolicy: 'network-only',
|
|
2150
|
-
}).pipe(map(result => ({
|
|
2151
|
-
id: result.data.placeOrder.order.order_number,
|
|
2152
|
-
orderId: result.data.placeOrder.order.order_number,
|
|
2153
|
-
cartId,
|
|
2154
|
-
})), catchError(err => throwError(() => transformCartMagentoError(err))));
|
|
2155
|
-
}
|
|
2156
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartOrderService, deps: [{ token: DAFF_MAGENTO_CART_MUTATION_QUEUE }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2157
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartOrderService, providedIn: 'root' }); }
|
|
2158
|
-
}
|
|
2159
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartOrderService, decorators: [{
|
|
2160
|
-
type: Injectable,
|
|
2161
|
-
args: [{
|
|
2162
|
-
providedIn: 'root',
|
|
2163
|
-
}]
|
|
2164
|
-
}], ctorParameters: () => [{ type: i5.DaffQueuedApollo, decorators: [{
|
|
2165
|
-
type: Inject,
|
|
2166
|
-
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
2167
|
-
}] }] });
|
|
2168
|
-
|
|
2169
|
-
/**
|
|
2170
|
-
* Transforms magento carts into an object usable by daffodil.
|
|
2171
|
-
*/
|
|
2172
|
-
class DaffMagentoCartCouponResponseTransformer {
|
|
2173
|
-
constructor(cartItemTransforms) {
|
|
2174
|
-
this.cartItemTransforms = cartItemTransforms;
|
|
2175
|
-
}
|
|
2176
|
-
transformCartItems(cart) {
|
|
2177
|
-
return {
|
|
2178
|
-
// TODO: extract into own transforms
|
|
2179
|
-
items: cart.items.filter(item => !!item).map(item => transformMagentoCartItem(daffTransformMagentoCartItem(item), item, this.cartItemTransforms)),
|
|
2180
|
-
};
|
|
2181
|
-
}
|
|
2182
|
-
transformCoupons(cart) {
|
|
2183
|
-
return {
|
|
2184
|
-
coupons: cart.applied_coupons
|
|
2185
|
-
? cart.applied_coupons.map(daffMagentoCouponTransform)
|
|
2186
|
-
: [],
|
|
2187
|
-
};
|
|
2188
|
-
}
|
|
2189
|
-
/**
|
|
2190
|
-
* Transforms the MagentoCart from the cart coupon operations into a DaffCart partial.
|
|
2191
|
-
*
|
|
2192
|
-
* @param cart the cart from a magento cart query.
|
|
2193
|
-
*/
|
|
2194
|
-
transform(cart) {
|
|
2195
|
-
return cart ? {
|
|
2196
|
-
...this.transformCartItems(cart),
|
|
2197
|
-
...this.transformCoupons(cart),
|
|
2198
|
-
...transformCartTotals(cart),
|
|
2199
|
-
id: cart.id,
|
|
2200
|
-
} : null;
|
|
2201
|
-
}
|
|
2202
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, deps: [{ token: DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2203
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, providedIn: 'root' }); }
|
|
2204
|
-
}
|
|
2205
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, decorators: [{
|
|
2206
|
-
type: Injectable,
|
|
2207
|
-
args: [{
|
|
2208
|
-
providedIn: 'root',
|
|
2209
|
-
}]
|
|
2210
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2211
|
-
type: Inject,
|
|
2212
|
-
args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS]
|
|
2213
|
-
}] }] });
|
|
2214
|
-
|
|
2215
|
-
class DaffCartMagentoDriverModule {
|
|
2216
|
-
static forRoot() {
|
|
2217
|
-
return {
|
|
2218
|
-
ngModule: DaffCartMagentoDriverModule,
|
|
2219
|
-
providers: [
|
|
2220
|
-
provideDaffCartDriver(DaffMagentoCartService),
|
|
2221
|
-
provideDaffCartItemDriver(DaffMagentoCartItemService),
|
|
2222
|
-
provideDaffCartAddressDriver(DaffMagentoCartAddressService),
|
|
2223
|
-
provideDaffCartBillingAddressDriver(DaffMagentoCartBillingAddressService),
|
|
2224
|
-
provideDaffCartShippingAddressDriver(DaffMagentoCartShippingAddressService),
|
|
2225
|
-
provideDaffCartShippingMethodsDriver(DaffMagentoCartShippingMethodsService),
|
|
2226
|
-
provideDaffCartShippingInformationDriver(DaffMagentoCartShippingInformationService),
|
|
2227
|
-
provideDaffCartPaymentDriver(DaffMagentoCartPaymentService),
|
|
2228
|
-
provideDaffCartPaymentMethodsDriver(DaffMagentoCartPaymentMethodsService),
|
|
2229
|
-
provideDaffCartOrderDriver(DaffMagentoCartOrderService),
|
|
2230
|
-
provideDaffCartCouponDriver(DaffMagentoCartCouponService),
|
|
2231
|
-
// output transformers
|
|
2232
|
-
DaffMagentoBillingAddressTransformer,
|
|
2233
|
-
DaffMagentoCartAddressTransformer,
|
|
2234
|
-
DaffMagentoCartPaymentTransformer,
|
|
2235
|
-
DaffMagentoCartShippingRateTransformer,
|
|
2236
|
-
DaffMagentoCartTransformer,
|
|
2237
|
-
DaffMagentoShippingAddressTransformer,
|
|
2238
|
-
DaffMagentoCartCouponResponseTransformer,
|
|
2239
|
-
// input transformers
|
|
2240
|
-
DaffMagentoCartAddressInputTransformer,
|
|
2241
|
-
DaffMagentoShippingAddressInputTransformer,
|
|
2242
|
-
DaffMagentoBillingAddressInputTransformer,
|
|
2243
|
-
DaffMagentoCartItemUpdateInputTransformer,
|
|
2244
|
-
DaffMagentoPaymentMethodInputTransformer,
|
|
2245
|
-
DaffMagentoShippingMethodInputTransformer,
|
|
2246
|
-
daffCartDriverProvideFreePaymentMethod({
|
|
2247
|
-
method: 'free',
|
|
2248
|
-
payment_info: {
|
|
2249
|
-
code: 'free',
|
|
2250
|
-
},
|
|
2251
|
-
}),
|
|
2252
|
-
],
|
|
2253
|
-
};
|
|
2254
|
-
}
|
|
2255
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartMagentoDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2256
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffCartMagentoDriverModule, imports: [CommonModule] }); }
|
|
2257
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartMagentoDriverModule, imports: [CommonModule] }); }
|
|
2258
|
-
}
|
|
2259
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartMagentoDriverModule, decorators: [{
|
|
2260
|
-
type: NgModule,
|
|
2261
|
-
args: [{
|
|
2262
|
-
imports: [
|
|
2263
|
-
CommonModule,
|
|
2264
|
-
],
|
|
2265
|
-
}]
|
|
2266
|
-
}] });
|
|
2267
|
-
|
|
2268
|
-
/**
|
|
2269
|
-
* Generated bundle index. Do not edit.
|
|
2270
|
-
*/
|
|
2271
|
-
|
|
2272
|
-
export { DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS, DAFF_CART_MAGENTO_CART_TRANSFORMS, DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS, DAFF_MAGENTO_GET_RECOVERABLE_ERRORS, DaffCartMagentoDriverModule, DaffMagentoBillingAddressInputTransformer, DaffMagentoBillingAddressTransformer, DaffMagentoCartAddressInputTransformer, DaffMagentoCartAddressService, DaffMagentoCartAddressTransformer, DaffMagentoCartBillingAddressService, DaffMagentoCartItemService, DaffMagentoCartItemUpdateInputTransformer, DaffMagentoCartPaymentMethodsService, DaffMagentoCartPaymentService, DaffMagentoCartPaymentTransformer, DaffMagentoCartService, DaffMagentoCartShippingAddressService, DaffMagentoCartShippingInformationService, DaffMagentoCartShippingMethodsService, DaffMagentoCartShippingRateTransformer, DaffMagentoCartTransformer, DaffMagentoPaymentMethodInputTransformer, DaffMagentoShippingAddressInputTransformer, DaffMagentoShippingAddressTransformer, DaffMagentoShippingMethodInputTransformer, MagentoCartItemTypeEnum, MagentoCartUserInputErrorType, addCartItem, applyCoupon, availablePaymentMethodFragment, availableShippingMethodFragment, cartAddressFragment, cartCouponFragment, cartFragment, cartItemFragment, createCart, getBillingAddress, getCart, getSelectedPaymentMethod, getSelectedShippingMethod, getShippingAddress, listCartCoupons, listCartItems, listPaymentMethods, listShippingMethods, magentoCartUserError, magentoMergeCartsMutation, placeOrder, pricesFragment, provideDaffCartMagentoCartItemTransformFactories, provideDaffCartMagentoCartItemTransforms, provideDaffCartMagentoCartTransformFactories, provideDaffCartMagentoCartTransforms, provideDaffCartMagentoExtraCartFragmentFactories, provideDaffCartMagentoExtraCartFragments, removeAllCoupons, removeCartItem, selectedPaymentMethodFragment, selectedShippingMethodFragment, setSelectedPaymentMethod, setSelectedPaymentMethodWithBilling, setSelectedPaymentMethodWithBillingAndEmail, setSelectedShippingMethod, transformMagentoCartGraphQlError, updateAddress, updateAddressWithEmail, updateBillingAddress, updateBillingAddressWithEmail, updateCartItem, updateShippingAddress, updateShippingAddressWithEmail };
|
|
2273
|
-
//# sourceMappingURL=daffodil-cart-driver-magento.mjs.map
|