Order Discount
Applies discounts to the total order value, including items, delivery, and payment fees. This is the most comprehensive discount type.
Included in Base Preset
Registered automatically by registerBasePlugins() / registerAllPlugins().
Registration
import { pluginRegistry } from '@unchainedshop/core';
import { OrderDiscountPlugin } from '@unchainedshop/plugins/pricing/order-discount';
pluginRegistry.register(OrderDiscountPlugin);
How It Works
- Calculates totals for items, delivery, and payment
- Determines proportional shares for each category
- For each discount:
- First applies to items (up to items total)
- Remaining discount applies to delivery and payment
- Distributes discounts proportionally for correct tax calculation
- Adds discount and tax adjustments to the order pricing
Discount Distribution Example
Items Total: 80 CHF
Delivery: 15 CHF
Payment: 5 CHF
Order Total: 100 CHF
10% Discount (10 CHF):
- Items: 8 CHF
- Delivery: 1.50 CHF
- Payment: 0.50 CHF
Fixed Rate Handling
For fixed-rate discounts that exceed the items total:
Items Total: 50 CHF
Delivery: 20 CHF
Fixed Discount: 60 CHF
Result:
- Items discount: 50 CHF (full amount)
- Delivery discount: 10 CHF (remaining)
Adapter Details
| Property | Value |
|---|---|
| Key | shop.unchained.pricing.order-discount |
| Version | 1.0.0 |
| Order Index | 40 |
| Source | pricing/order-discount |
Related
- Discount 100 Off - Example fixed discount
- Order Discounts - Creating custom discounts