@reactionary/commercetools 0.9.18 → 0.9.20

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.
@@ -41,7 +41,11 @@ class CommercetoolsCategoryCapability extends CategoryCapability {
41
41
  async getById(payload) {
42
42
  const client = await this.getClient();
43
43
  try {
44
- const response = await client.withKey({ key: payload.id.key }).get().execute();
44
+ const response = await client.withKey({ key: payload.id.key }).get({
45
+ queryArgs: {
46
+ expand: "parent"
47
+ }
48
+ }).execute();
45
49
  return success(this.factory.parseCategory(this.context, response.body));
46
50
  } catch (err) {
47
51
  return error({
@@ -55,6 +59,7 @@ class CommercetoolsCategoryCapability extends CategoryCapability {
55
59
  try {
56
60
  const response = await client.get({
57
61
  queryArgs: {
62
+ expand: "parent",
58
63
  where: `slug(${getLanguageCodeFromLocale(this.context.languageContext.locale)}=:slug)`,
59
64
  "var.slug": payload.slug,
60
65
  storeProjection: this.context.storeIdentifier.key,
@@ -108,6 +113,7 @@ class CommercetoolsCategoryCapability extends CategoryCapability {
108
113
  const parentCategory = await client.withKey({ key: payload.parentId.key }).get().execute();
109
114
  const response = await client.get({
110
115
  queryArgs: {
116
+ expand: "parent",
111
117
  where: "parent(id = :parentId)",
112
118
  "var.parentId": parentCategory.body.id,
113
119
  limit: payload.paginationOptions.pageSize,
@@ -103,15 +103,16 @@ class CommercetoolsCheckoutFactory {
103
103
  const identifier = {
104
104
  key: data.key || ""
105
105
  };
106
+ const rate = data.zoneRates[0]?.shippingRates.find((x) => x.isMatching);
106
107
  const result = {
107
108
  deliveryTime: "",
108
109
  description: data.localizedDescription?.[getLanguageCodeFromLocale(context.languageContext.locale)] || "",
109
110
  identifier,
110
111
  name: data.name,
111
- price: data.zoneRates[0].shippingRates[0].price ? {
112
- value: (data.zoneRates[0].shippingRates[0].price.centAmount || 0) / 100,
113
- currency: data.zoneRates[0].shippingRates[0].price.currencyCode || context.languageContext.currencyCode
114
- } : { value: 0, currency: context.languageContext.currencyCode }
112
+ price: {
113
+ value: (rate?.price.centAmount || 0) / 100,
114
+ currency: rate?.price.currencyCode
115
+ }
115
116
  };
116
117
  return this.shippingMethodSchema.parse(result);
117
118
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@reactionary/commercetools",
3
- "version": "0.9.18",
3
+ "version": "0.9.20",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
- "@reactionary/core": "0.9.18",
8
+ "@reactionary/core": "0.9.20",
9
9
  "zod": "4.1.9",
10
10
  "@commercetools/ts-client": "^4.9.1",
11
11
  "@commercetools/platform-sdk": "^8.25.0",