-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathTask04c_merging.js
More file actions
33 lines (26 loc) · 1.13 KB
/
Copy pathTask04c_merging.js
File metadata and controls
33 lines (26 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const checkout = require("./handson/order");
const { log } = require("./logger.js");
const customerKey = "";
const mergingProcessTest = async () => {
let anonymousCart = await checkout.createAnonymousCart();
let customerCart = await checkout.createCart(customerKey);
anonymousCart = await checkout.addLineItemsToCart( anonymousCart.body.id,['tulip-seed-box','tulip-seed-box','tulip-seed-box'] );
customerCart = await checkout.addLineItemsToCart( customerCart.body.id, ['tulip-seed-box','tulip-seed-sack','tulip-seed-package'] );
log("Anonymous Cart: " + anonymousCart.body.id);
log("Customer Cart: "+ customerCart.body.id);
const customerDetails = {
email: "test@test.com",
password: "password",
anonymousCartId: anonymousCart.body.id,
anonymousCartSignInMode: "MergeWithExistingCustomerCart", // try switching to UseAsNewActiveCustomerCart
};
let result = await checkout.customerSignIn(customerDetails);
return result.body.cart;
};
mergingProcessTest().then((cart) => {
log("Active cart: " + cart.id);
cart.lineItems.forEach(item => {
log(item.variant.sku+ " :" + item.quantity);
});
})
.catch(log);