@labdigital/commercetools-mock 2.21.2 → 2.22.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/dist/index.cjs +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/cart/actions.ts +20 -0
- package/src/repositories/helpers.ts +1 -2
- package/src/repositories/order/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CartSetAnonymousIdAction,
|
|
3
|
+
CartSetCustomerIdAction,
|
|
2
4
|
CartUpdateAction,
|
|
3
5
|
type Address,
|
|
4
6
|
type AddressDraft,
|
|
@@ -281,6 +283,15 @@ export class CartUpdateHandler
|
|
|
281
283
|
resource.totalPrice.centAmount = calculateCartTotalPrice(resource);
|
|
282
284
|
}
|
|
283
285
|
|
|
286
|
+
setAnonymousId(
|
|
287
|
+
_context: RepositoryContext,
|
|
288
|
+
resource: Writable<Cart>,
|
|
289
|
+
{ anonymousId }: CartSetAnonymousIdAction,
|
|
290
|
+
) {
|
|
291
|
+
resource.anonymousId = anonymousId;
|
|
292
|
+
resource.customerId = undefined;
|
|
293
|
+
}
|
|
294
|
+
|
|
284
295
|
setBillingAddress(
|
|
285
296
|
context: RepositoryContext,
|
|
286
297
|
resource: Writable<Cart>,
|
|
@@ -309,6 +320,15 @@ export class CartUpdateHandler
|
|
|
309
320
|
resource.customerEmail = email;
|
|
310
321
|
}
|
|
311
322
|
|
|
323
|
+
setCustomerId(
|
|
324
|
+
_context: RepositoryContext,
|
|
325
|
+
resource: Writable<Cart>,
|
|
326
|
+
{ customerId }: CartSetCustomerIdAction,
|
|
327
|
+
) {
|
|
328
|
+
resource.anonymousId = undefined;
|
|
329
|
+
resource.customerId = customerId;
|
|
330
|
+
}
|
|
331
|
+
|
|
312
332
|
setCustomField(
|
|
313
333
|
context: RepositoryContext,
|
|
314
334
|
resource: Cart,
|
|
@@ -60,7 +60,6 @@ export const createCustomFields = (
|
|
|
60
60
|
if (!draft) return undefined;
|
|
61
61
|
if (!draft.type) return undefined;
|
|
62
62
|
if (!draft.type.typeId) return undefined;
|
|
63
|
-
if (!draft.fields) return undefined;
|
|
64
63
|
const typeResource = storage.getByResourceIdentifier(
|
|
65
64
|
projectKey,
|
|
66
65
|
draft.type,
|
|
@@ -77,7 +76,7 @@ export const createCustomFields = (
|
|
|
77
76
|
typeId: draft.type.typeId,
|
|
78
77
|
id: typeResource.id,
|
|
79
78
|
},
|
|
80
|
-
fields: draft.fields,
|
|
79
|
+
fields: draft.fields ?? {},
|
|
81
80
|
};
|
|
82
81
|
};
|
|
83
82
|
|