@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
49 lines (38 loc) • 1.24 kB
text/typescript
import {
OrderDiscountDirector,
OrderDiscountAdapter,
OrderDiscountConfiguration,
IDiscountAdapter,
} from '@unchainedshop/core';
export const HundredOff: IDiscountAdapter<OrderDiscountConfiguration> = {
...OrderDiscountAdapter,
key: 'shop.unchained.discount.100-off',
label: '100 Off',
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.toUpperCase() === '100OFF';
},
// returns the appropriate discount context for a calculation adapter
discountForPricingAdapterKey: ({ pricingAdapterKey }) => {
if (pricingAdapterKey === 'shop.unchained.pricing.order-discount') {
return { fixedRate: 10000 };
}
return null;
},
}),
};
OrderDiscountDirector.registerAdapter(HundredOff);