Discount 100 Off
A sample discount adapter demonstrating a fixed-amount coupon code (10000 minor units of the order currency, such as 100 CHF). Use this as a template for implementing your own coupon systems.
Registration
Not part of any preset — register it explicitly:
import { pluginRegistry } from '@unchainedshop/core';
import { HundredOffPlugin } from '@unchainedshop/plugins/pricing/discount-100-off';
pluginRegistry.register(HundredOffPlugin);
How It Works
- User enters coupon code
100OFF - Adapter validates the code
- Returns a fixed discount of 10000 minor units to be applied by Order Discount
Coupon Code
| Code | Effect |
|---|---|
100OFF | 10000 minor units off the total order (case-insensitive; 100.00 for currencies with two decimals) |
Usage
Apply the discount:
mutation ApplyDiscount {
addCartDiscount(code: "100OFF") {
_id
total {
amount
currencyCode
}
}
}
Remove the discount:
mutation RemoveDiscount {
removeCartDiscount(discountId: "discount-id") {
_id
}
}
Configuration
The adapter targets shop.unchained.pricing.order-discount:
discountForPricingAdapterKey: ({ pricingAdapterKey }) => {
if (pricingAdapterKey === 'shop.unchained.pricing.order-discount') {
return { fixedRate: 10000 }; // 100.00 for currencies with two decimals
}
return null;
},
Adapter Details
| Property | Value |
|---|---|
| Key | shop.unchained.discount.100-off |
| Version | 1.0.0 |
| Order Index | 10 |
| Manual Addition | Yes |
| Manual Removal | Yes |
| System Triggering | No |
| Source | pricing/discount-100-off |
Related
- Discount Half Price Manual - Percentage discount
- Order Discount - Order-level discount pricing
- Order Discounts - Creating custom discounts