Skip to main content

Discount 100 Off

A sample discount adapter demonstrating a fixed-amount coupon code (100 CHF off). Use this as a template for implementing your own coupon systems.

Installation

import '@unchainedshop/plugins/pricing/discount-100-off';

How It Works

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

Coupon Code

CodeEffect
100OFF100.00 off total order (case-insensitive)

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 in cents
}
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.ts