Skip to main content

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

  1. User enters coupon code HALFPRICE
  2. Adapter validates the code
  3. Returns 50% discount to be applied by Product Discount

Coupon Code

CodeEffect
HALFPRICE50% off all products (case-sensitive)

Usage

Apply the discount:

mutation ApplyDiscount {
addCartDiscount(code: "HALFPRICE") {
_id
total {
amount
currencyCode
}
}
}

Difference from Half Price

AdapterTriggerRemoval
Half PriceAutomatic (user tag)Not removable
Half Price ManualCoupon codeUser 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

PropertyValue
Keyshop.unchained.discount.half-price-manual
Version1.0.0
Order Index10
Manual AdditionYes
Manual RemovalYes
System TriggeringNo
Sourcepricing/discount-half-price-manual.ts