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.

Registration​

Not part of any preset — register it explicitly:

import { pluginRegistry } from '@unchainedshop/core';
import { HalfPriceManualPlugin } from '@unchainedshop/plugins/pricing/discount-half-price-manual';

pluginRegistry.register(HalfPriceManualPlugin);

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
}
}
}

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