UNPKG

@unchainedshop/plugins

Version:

Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters

31 lines (30 loc) 1.01 kB
import { OrderDiscountDirector, OrderDiscountAdapter, } from '@unchainedshop/core'; export const HalfPriceManual = { ...OrderDiscountAdapter, key: 'shop.unchained.discount.half-price-manual', label: 'Half Price Manual', 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 === 'HALFPRICE'; }, discountForPricingAdapterKey({ pricingAdapterKey }) { if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') { return { rate: 0.5 }; } return null; }, }), }; OrderDiscountDirector.registerAdapter(HalfPriceManual);