Discount Half Price
A sample discount adapter demonstrating automatic system-triggered discounts. Applies 50% off to users with the half-price tag.
Installation
import '@unchainedshop/plugins/pricing/discount-half-price';
How It Works
- System automatically checks all orders during pricing
- Looks for users with the
half-pricetag - If found, applies 50% off to all products via Product Discount
Eligibility
Users must have the half-price tag:
mutation TagUser {
updateUser(
userId: "user-id"
user: {
tags: ["half-price"]
}
) {
_id
tags
}
}
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;
},
Use Cases
- Employee discounts
- VIP customer pricing
- Partner/affiliate discounts
- Loyalty rewards
Adapter Details
| Property | Value |
|---|---|
| Key | shop.unchained.discount.half-price |
| Version | 1.0.0 |
| Order Index | 10 |
| Manual Addition | No |
| Manual Removal | No |
| System Triggering | Yes (user tag check) |
| Source | pricing/discount-half-price.ts |
Related
- Discount Half Price Manual - Code-based version
- Discount 100 Off - Fixed amount discount
- Product Discount - Product-level discounts