Skip to main content

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

  1. System automatically checks all orders during pricing
  2. Looks for users with the half-price tag
  3. 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

PropertyValue
Keyshop.unchained.discount.half-price
Version1.0.0
Order Index10
Manual AdditionNo
Manual RemovalNo
System TriggeringYes (user tag check)
Sourcepricing/discount-half-price.ts