@unchainedshop/plugins
Version:
Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters
31 lines (30 loc) • 1 kB
JavaScript
import { OrderDiscountDirector, OrderDiscountAdapter, } from '@unchainedshop/core';
export const HundredOff = {
...OrderDiscountAdapter,
key: 'shop.unchained.discount.100-off',
label: '100 Off',
version: '1.0.0',
orderIndex: 10,
isManualAdditionAllowed: async () => {
return true;
},
isManualRemovalAllowed: async () => {
return true;
},
actions: async ({ context }) => ({
...(await OrderDiscountAdapter.actions({ context })),
isValidForSystemTriggering: async () => {
return false;
},
isValidForCodeTriggering: async ({ code }) => {
return code.toUpperCase() === '100OFF';
},
discountForPricingAdapterKey: ({ pricingAdapterKey }) => {
if (pricingAdapterKey === 'shop.unchained.pricing.order-discount') {
return { fixedRate: 10000 };
}
return null;
},
}),
};
OrderDiscountDirector.registerAdapter(HundredOff);