Discount Half Price Manual
A sample discount adapter demonstrating a percentage-based coupon code. Applies 50% off to all products when code is entered.
Installation
import '@unchainedshop/plugins/pricing/discount-half-price-manual';
How It Works
- User enters coupon code
HALFPRICE - Adapter validates the code
- Returns 50% discount to be applied by Product Discount
Coupon Code
| Code | Effect |
|---|---|
HALFPRICE | 50% off all products (case-sensitive) |
Usage
Apply the discount:
mutation ApplyDiscount {
addCartDiscount(code: "HALFPRICE") {
_id
total {
amount
currencyCode
}
}
}
Difference from Half Price
| Adapter | Trigger | Removal |
|---|---|---|
| Half Price | Automatic (user tag) | Not removable |
| Half Price Manual | Coupon code | User can remove |
Configuration
The adapter targets shop.unchained.pricing.product-discount:
discountForPricingAdapterKey({ pricingAdapterKey }) {
if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
return { rate: 0.5 }; // 50% off
}
return null;
},
Adapter Details
| Property | Value |
|---|---|
| Key | shop.unchained.discount.half-price-manual |
| Version | 1.0.0 |
| Order Index | 10 |
| Manual Addition | Yes |
| Manual Removal | Yes |
| System Triggering | No |
| Source | pricing/discount-half-price-manual.ts |
Related
- Discount Half Price - Automatic version
- Discount 100 Off - Fixed amount discount
- Order Discounts - Creating custom discounts