Skip to main content

Discount 100 Off

A sample discount adapter demonstrating a fixed-amount coupon code (10000 minor units of the order currency, such as 100 CHF). Use this as a template for implementing your own coupon systems.

Registration​

Not part of any preset — register it explicitly:

import { pluginRegistry } from '@unchainedshop/core';
import { HundredOffPlugin } from '@unchainedshop/plugins/pricing/discount-100-off';

pluginRegistry.register(HundredOffPlugin);

How It Works​

  1. User enters coupon code 100OFF
  2. Adapter validates the code
  3. Returns a fixed discount of 10000 minor units to be applied by Order Discount

Coupon Code​

CodeEffect
100OFF10000 minor units off the total order (case-insensitive; 100.00 for currencies with two decimals)

Usage​

Apply the discount:

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

Remove the discount:

mutation RemoveDiscount {
removeCartDiscount(discountId: "discount-id") {
_id
}
}

Configuration​

The adapter targets shop.unchained.pricing.order-discount:

discountForPricingAdapterKey: ({ pricingAdapterKey }) => {
if (pricingAdapterKey === 'shop.unchained.pricing.order-discount') {
return { fixedRate: 10000 }; // 100.00 for currencies with two decimals
}
return null;
},

Adapter Details​

PropertyValue
Keyshop.unchained.discount.100-off
Version1.0.0
Order Index10
Manual AdditionYes
Manual RemovalYes
System TriggeringNo
Sourcepricing/discount-100-off