@reactionary/medusa 0.10.45 → 0.10.47
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.
|
@@ -114,6 +114,22 @@ class MedusaCheckoutCapability extends CheckoutCapability {
|
|
|
114
114
|
cart_id: payload.checkout.key
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Whether a Medusa shipping option's calculated price is usable, i.e. has an
|
|
119
|
+
* actual amount (which may be `0` for valid free shipping) rather than no
|
|
120
|
+
* price data at all. `calculated_amount`/`original_amount` are `number | null`;
|
|
121
|
+
* checking them with a plain falsy check would incorrectly treat a `0` amount
|
|
122
|
+
* (free shipping) the same as a missing price and drop the option.
|
|
123
|
+
*
|
|
124
|
+
* Override this if a project needs different rules for which shipping
|
|
125
|
+
* options are considered usable.
|
|
126
|
+
*/
|
|
127
|
+
hasUsableShippingPrice(calculatedPrice) {
|
|
128
|
+
if (!calculatedPrice) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return calculatedPrice.calculated_amount != null || calculatedPrice.original_amount != null;
|
|
132
|
+
}
|
|
117
133
|
async getAvailableShippingMethods(payload) {
|
|
118
134
|
const client = await this.medusaApi.getClient();
|
|
119
135
|
if (debug.enabled) {
|
|
@@ -148,7 +164,7 @@ class MedusaCheckoutCapability extends CheckoutCapability {
|
|
|
148
164
|
}
|
|
149
165
|
}
|
|
150
166
|
for (const sm of shippingMethodResponse.shipping_options) {
|
|
151
|
-
if (!
|
|
167
|
+
if (!this.hasUsableShippingPrice(sm.calculated_price)) {
|
|
152
168
|
console.warn(`Skipping shipping method ${sm.name}/${sm.provider.id} because it has no calculated price for checkout ${payload.checkout.key}`);
|
|
153
169
|
continue;
|
|
154
170
|
}
|
|
@@ -74,7 +74,7 @@ class MedusaOrderSearchFactory {
|
|
|
74
74
|
pageNumber: (Math.ceil(data.offset / data.limit) || 0) + 1,
|
|
75
75
|
pageSize: data.limit,
|
|
76
76
|
totalCount: data.count,
|
|
77
|
-
totalPages: Math.ceil(data.count / data.limit || 0)
|
|
77
|
+
totalPages: Math.ceil(data.count / data.limit || 0),
|
|
78
78
|
items: orders
|
|
79
79
|
};
|
|
80
80
|
return this.orderSearchResultSchema.parse(result);
|
|
@@ -20,7 +20,7 @@ class MedusaProductSearchFactory {
|
|
|
20
20
|
pageNumber: (Math.ceil(remote.offset / remote.limit) || 0) + 1,
|
|
21
21
|
pageSize: remote.limit,
|
|
22
22
|
totalCount: remote.count,
|
|
23
|
-
totalPages: Math.ceil(remote.count / remote.limit || 0)
|
|
23
|
+
totalPages: Math.ceil(remote.count / remote.limit || 0),
|
|
24
24
|
items: products,
|
|
25
25
|
facets: []
|
|
26
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/medusa",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@medusajs/js-sdk": "^2.13.3",
|
|
13
|
-
"@reactionary/core": "0.10.
|
|
13
|
+
"@reactionary/core": "0.10.47",
|
|
14
14
|
"debug": "^4.4.3",
|
|
15
15
|
"@medusajs/types": "^2.13.3",
|
|
16
16
|
"zod": "4.1.9"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StoreAddCartShippingMethods, StoreInitializePaymentSession, StoreUpdateCart } from '@medusajs/types';
|
|
1
|
+
import type { StoreAddCartShippingMethods, StoreCalculatedPrice, StoreInitializePaymentSession, StoreUpdateCart } from '@medusajs/types';
|
|
2
2
|
import type { Address, Cache, CheckoutFactory, CheckoutFactoryCheckoutOutput, CheckoutFactoryPaymentMethodOutput, CheckoutFactoryShippingMethodOutput, CheckoutFactoryWithOutput, CheckoutIdentifier, CheckoutMutationAddPaymentInstruction, CheckoutMutationFinalizeCheckout, CheckoutMutationInitiateCheckout, CheckoutMutationRemovePaymentInstruction, CheckoutMutationSetShippingAddress, CheckoutMutationSetShippingInstruction, CheckoutQueryById, CheckoutQueryForAvailablePaymentMethods, CheckoutQueryForAvailableShippingMethods, NotFoundError, RequestContext, Result } from '@reactionary/core';
|
|
3
3
|
import { CheckoutCapability } from '@reactionary/core';
|
|
4
4
|
import type { MedusaAPI } from '../core/client.js';
|
|
@@ -28,6 +28,17 @@ export declare class MedusaCheckoutCapability<TFactory extends CheckoutFactory =
|
|
|
28
28
|
protected getAvailableShippingMethodsPayload(payload: CheckoutQueryForAvailableShippingMethods): {
|
|
29
29
|
cart_id: string;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Whether a Medusa shipping option's calculated price is usable, i.e. has an
|
|
33
|
+
* actual amount (which may be `0` for valid free shipping) rather than no
|
|
34
|
+
* price data at all. `calculated_amount`/`original_amount` are `number | null`;
|
|
35
|
+
* checking them with a plain falsy check would incorrectly treat a `0` amount
|
|
36
|
+
* (free shipping) the same as a missing price and drop the option.
|
|
37
|
+
*
|
|
38
|
+
* Override this if a project needs different rules for which shipping
|
|
39
|
+
* options are considered usable.
|
|
40
|
+
*/
|
|
41
|
+
protected hasUsableShippingPrice(calculatedPrice: StoreCalculatedPrice | null | undefined): boolean;
|
|
31
42
|
getAvailableShippingMethods(payload: CheckoutQueryForAvailableShippingMethods): Promise<Result<CheckoutFactoryShippingMethodOutput<TFactory>[]>>;
|
|
32
43
|
protected getAvailablePaymentMethodsPayload(payload: CheckoutQueryForAvailablePaymentMethods, regionId: string): {
|
|
33
44
|
region_id: string;
|