01 Software

Discounts

Discount and coupon collections

Discounts

discounts

Stores discount codes (coupons/promotions).

FieldTypeDescriptionRequired
codetextDiscount code (unique per tenant, indexed)
titletextDiscount name
typeselectDiscount type
valuenumberDiscount value (except tiered)
tiersarrayTiered discount rules (tiered only: minAmount, discountType, value)
minOrderAmountnumberMinimum order amount
maxDiscountAmountnumberMaximum discount amount
startsAtdateStart date
endsAtdateEnd date
usageLimitnumberTotal usage limit
usageCountnumberUsage count (read-only, default: 0)
perCustomerLimitnumberPer-customer usage limit
isActivecheckboxActive flag (default: true)
applicableProductsrelationship[]Applicable products (products)
applicableCategoriesrelationship[]Applicable categories (product-categories)

Discount Types:

ValueDescription
percentagePercentage discount (e.g., 10%)
fixed_amountFixed amount discount (e.g., $5)
free_shippingFree shipping
tieredTiered discount (varies by order amount)
// Create a discount
const discount = await client.from('discounts').create({
  code: 'WELCOME10',
  title: 'New member 10% off',
  type: 'percentage',
  value: 10,
  minOrderAmount: 30000,
  maxDiscountAmount: 10000,
  isActive: true
})

// Find discount by code
const response = await client.from('discounts').find({
  where: {
    code: { equals: 'WELCOME10' },
    isActive: { equals: true }
  }
})

// List active discounts
const response = await client.from('discounts').find({
  where: {
    isActive: { equals: true },
    endsAt: { greater_than: new Date().toISOString() }
  }
})

On this page