UNPKG

@unchainedshop/plugins

Version:

Because of a Typescript issue with upstream "postfinancecheckout", the Postfinance plugin has been disabled from transpilation, import the source ts files from src and enable node_module tsc or copy over the src/payment/postfinance-checkout to your projec

35 lines 1.35 kB
import { OrderPricingDirector, OrderPricingAdapter, DeliveryPricingSheet, } from '@unchainedshop/core'; export const OrderDelivery = { ...OrderPricingAdapter, key: 'shop.unchained.pricing.order-delivery', version: '1.0.0', label: 'Add Delivery Fees to Order', orderIndex: 10, isActivatedFor: () => { return true; }, actions: (params) => { const pricingAdapter = OrderPricingAdapter.actions(params); const { order, orderDelivery } = params.context; return { ...pricingAdapter, calculate: async () => { // just add tax + net price to order pricing if (!orderDelivery) return null; const pricing = DeliveryPricingSheet({ calculation: orderDelivery.calculation, currency: order.currency, }); const tax = pricing.taxSum(); const shipping = pricing.gross(); pricingAdapter .resultSheet() .addDelivery({ amount: shipping, taxAmount: tax, meta: { adapter: OrderDelivery.key } }); return pricingAdapter.calculate(); }, }; }, }; OrderPricingDirector.registerAdapter(OrderDelivery); //# sourceMappingURL=order-delivery.js.map