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

48 lines (38 loc) 1.25 kB
import { OrderDiscountDirector, OrderDiscountAdapter, ProductDiscountConfiguration, IDiscountAdapter, } from '@unchainedshop/core'; export const HalfPriceManual: IDiscountAdapter<ProductDiscountConfiguration> = { ...OrderDiscountAdapter, key: 'shop.unchained.discount.half-price-manual', label: 'Half Price Manual', version: '1.0.0', orderIndex: 10, // return true if a discount is allowed to get added manually by a user isManualAdditionAllowed: async () => { return true; }, // return true if a discount is allowed to get removed manually by a user isManualRemovalAllowed: async () => { return true; }, actions: async ({ context }) => ({ ...(await OrderDiscountAdapter.actions({ context })), isValidForSystemTriggering: async () => { return false; }, isValidForCodeTriggering: async ({ code }) => { return code === 'HALFPRICE'; }, // returns the appropriate discount context for a calculation adapter discountForPricingAdapterKey({ pricingAdapterKey }) { if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') { return { rate: 0.5 }; } return null; }, }), }; OrderDiscountDirector.registerAdapter(HalfPriceManual);