-
Notifications
You must be signed in to change notification settings - Fork 0
/
additional-fees.js
25 lines (22 loc) · 970 Bytes
/
additional-fees.js
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
import * as ecomAdditionalFees from 'interfaces-ecommerce-v1-additional-fees-provider';
/**
* Get additional fees from all providers (implementers)
* @param {import('interfaces-ecommerce-v1-additional-fees-provider').CalculateAdditionalFeesOptions} options
* @param {import('interfaces-ecommerce-v1-additional-fees-provider').Context} context
* @returns {Promise<import('interfaces-ecommerce-v1-additional-fees-provider').CalculateAdditionalFeesResponse>}
*/
export const calculateAdditionalFees = async (options, context) => {
const additionalFees = [];
const hasFragileItem = options.lineItems.some(item => item.productName.toLowerCase().includes('tea pot') || item.productName.toLowerCase().includes('tea glass'))
if(hasFragileItem){
additionalFees.push({
code:'special-packaging',
name:'Special Packaging',
price:'2'
})
}
return{
additionalFees,
currency:'USD'
}
};