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
This plugin is part of the base preset and loaded automatically. Using the base preset is strongly recommended, so explicit installation is usually not required.
Installation
import '@unchainedshop/plugins/pricing/order-discount';
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.ts |
Related
- Order Items Discount - Items-only discounts
- Discount 100 Off - Example fixed discount
- Order Discounts - Creating custom discounts