@scayle/storefront-core 7.66.4 → 7.66.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 7.66.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Merging wishlists now retains the `variantId`, `itemGroup` and `customData` when present on the source wishlist item.
8
+
3
9
  ## 7.66.4
4
10
 
5
11
  ### Patch Changes
@@ -37,7 +37,7 @@ const getCheckoutToken = exports.getCheckoutToken = async function getCheckoutTo
37
37
  carrier,
38
38
  basketId: context.basketKey,
39
39
  campaignKey: context.campaignKey
40
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.66.4"}`).setProtectedHeader({
40
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.66.5"}`).setProtectedHeader({
41
41
  alg: "HS256",
42
42
  typ: "JWT"
43
43
  }).sign(secret);
@@ -35,7 +35,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
35
35
  carrier,
36
36
  basketId: context.basketKey,
37
37
  campaignKey: context.campaignKey
38
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.66.4"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
38
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.66.5"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
39
39
  return {
40
40
  accessToken: refreshedAccessToken,
41
41
  checkoutJwt
@@ -62,12 +62,25 @@ const mergeWishlists = async (fromWishlistKey, toWishlistKey, withOptions, conte
62
62
  context.log.debug(`Merging wishlist ${fromWishlistKey} to ${toWishlistKey}`);
63
63
  if (oldWishlist != null) {
64
64
  for (const item of oldWishlist.items) {
65
- const productId = item?.product?.id;
66
- if (productId) {
65
+ const {
66
+ productId,
67
+ variantId
68
+ } = item;
69
+ if (productId || variantId) {
67
70
  await bapiClient.wishlist.addItem(toWishlistKey, {
68
- productId
71
+ ...(variantId ? {
72
+ variantId
73
+ } : {
74
+ productId
75
+ })
69
76
  }, {
70
- campaignKey
77
+ campaignKey,
78
+ ...(item.itemGroup ? {
79
+ itemGroup: item.itemGroup
80
+ } : void 0),
81
+ ...(item.customData && Object.keys(item.customData).length ? {
82
+ customData: item.customData
83
+ } : void 0)
71
84
  });
72
85
  bapiClient.wishlist.deleteItem(fromWishlistKey, item?.key);
73
86
  }
@@ -51,14 +51,18 @@ export const mergeWishlists = async (fromWishlistKey, toWishlistKey, withOptions
51
51
  context.log.debug(`Merging wishlist ${fromWishlistKey} to ${toWishlistKey}`);
52
52
  if (oldWishlist != null) {
53
53
  for (const item of oldWishlist.items) {
54
- const productId = item?.product?.id;
55
- if (productId) {
54
+ const { productId, variantId } = item;
55
+ if (productId || variantId) {
56
56
  await bapiClient.wishlist.addItem(
57
57
  toWishlistKey,
58
58
  {
59
- productId
59
+ ...variantId ? { variantId } : { productId }
60
60
  },
61
- { campaignKey }
61
+ {
62
+ campaignKey,
63
+ ...item.itemGroup ? { itemGroup: item.itemGroup } : void 0,
64
+ ...item.customData && Object.keys(item.customData).length ? { customData: item.customData } : void 0
65
+ }
62
66
  );
63
67
  bapiClient.wishlist.deleteItem(fromWishlistKey, item?.key);
64
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "7.66.4",
3
+ "version": "7.66.5",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",