@reactionary/feeds 0.10.36 → 0.10.38
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/cli.cjs +36 -6
- package/package.json +9 -9
package/cli.cjs
CHANGED
|
@@ -114938,16 +114938,46 @@ var init_checkout_capability2 = __esm({
|
|
|
114938
114938
|
}
|
|
114939
114939
|
async getAvailableShippingMethods(payload) {
|
|
114940
114940
|
const client = await this.getClient();
|
|
114941
|
-
const shippingMethodsResponse = await
|
|
114942
|
-
|
|
114943
|
-
|
|
114944
|
-
|
|
114945
|
-
|
|
114941
|
+
const [shippingMethodsResponse, cartResponse] = await Promise.all([
|
|
114942
|
+
client.shippingMethods.matchingCart().get({
|
|
114943
|
+
queryArgs: {
|
|
114944
|
+
cartId: payload.checkout.key
|
|
114945
|
+
}
|
|
114946
|
+
}).execute(),
|
|
114947
|
+
client.carts.withId({ ID: payload.checkout.key }).get().execute()
|
|
114948
|
+
]);
|
|
114946
114949
|
const result = shippingMethodsResponse.body.results.map(
|
|
114947
|
-
(shippingMethod) => this.factory.parseShippingMethod(this.context, shippingMethod)
|
|
114950
|
+
(shippingMethod) => this.factory.parseShippingMethod(this.context, this.withFreeShipping(shippingMethod, cartResponse.body))
|
|
114948
114951
|
);
|
|
114949
114952
|
return success(result);
|
|
114950
114953
|
}
|
|
114954
|
+
/**
|
|
114955
|
+
* Quotes the matching shipping rates as free where the cart reaches the
|
|
114956
|
+
* rate's free-above threshold. commercetools' matching-cart query returns
|
|
114957
|
+
* the rates at their configured price and only applies the threshold once
|
|
114958
|
+
* the method is set on the cart.
|
|
114959
|
+
*/
|
|
114960
|
+
withFreeShipping(shippingMethod, cart) {
|
|
114961
|
+
return {
|
|
114962
|
+
...shippingMethod,
|
|
114963
|
+
zoneRates: shippingMethod.zoneRates.map((zoneRate) => ({
|
|
114964
|
+
...zoneRate,
|
|
114965
|
+
shippingRates: zoneRate.shippingRates.map((rate) => rate.isMatching && this.isFreeShipping(rate, cart) ? { ...rate, price: { ...rate.price, centAmount: 0 } } : rate)
|
|
114966
|
+
}))
|
|
114967
|
+
};
|
|
114968
|
+
}
|
|
114969
|
+
/**
|
|
114970
|
+
* Whether commercetools charges nothing for the rate once the method is set:
|
|
114971
|
+
* shipping is free if the sum of the (custom) line item prices, after line
|
|
114972
|
+
* item discounts, reaches the rate's free-above threshold.
|
|
114973
|
+
*/
|
|
114974
|
+
isFreeShipping(rate, cart) {
|
|
114975
|
+
if (!rate.freeAbove || rate.freeAbove.currencyCode !== cart.totalPrice.currencyCode) {
|
|
114976
|
+
return false;
|
|
114977
|
+
}
|
|
114978
|
+
const itemsTotal = [...cart.lineItems, ...cart.customLineItems].reduce((sum, item) => sum + item.totalPrice.centAmount, 0);
|
|
114979
|
+
return itemsTotal >= rate.freeAbove.centAmount;
|
|
114980
|
+
}
|
|
114951
114981
|
async getAvailablePaymentMethods(payload) {
|
|
114952
114982
|
const staticMethods = this.getStaticPaymentMethods(payload.checkout);
|
|
114953
114983
|
const dynamicMethods = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/feeds",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"url": "git+https://github.com/Solteq/reactionary.git"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@reactionary/algolia": "0.10.
|
|
16
|
-
"@reactionary/commercetools": "0.10.
|
|
17
|
-
"@reactionary/core": "0.10.
|
|
18
|
-
"@reactionary/fake": "0.10.
|
|
19
|
-
"@reactionary/magento": "0.10.
|
|
20
|
-
"@reactionary/medusa": "0.10.
|
|
21
|
-
"@reactionary/meilisearch": "0.10.
|
|
22
|
-
"@reactionary/unomi": "0.10.
|
|
15
|
+
"@reactionary/algolia": "0.10.38",
|
|
16
|
+
"@reactionary/commercetools": "0.10.38",
|
|
17
|
+
"@reactionary/core": "0.10.38",
|
|
18
|
+
"@reactionary/fake": "0.10.38",
|
|
19
|
+
"@reactionary/magento": "0.10.38",
|
|
20
|
+
"@reactionary/medusa": "0.10.38",
|
|
21
|
+
"@reactionary/meilisearch": "0.10.38",
|
|
22
|
+
"@reactionary/unomi": "0.10.38",
|
|
23
23
|
"commander": "^15.0.0",
|
|
24
24
|
"dotenv": "^17.2.2",
|
|
25
25
|
"sitemap": "^9.0.1",
|