Discount Codes
Create and manage percentage and fixed-amount coupons.
Updated
On this page
Overview
Discount codes allow customers to get price reductions at checkout. Codes are created and managed in the dashboard.
Types of Discounts
| Type | Description | Example |
|---|---|---|
| Percentage | Reduce by a percentage of the subtotal | 20% off → SAVE20 |
| Fixed Amount | Reduce by a fixed dollar amount | $10 off → TENOFF |
| Free Shipping | Waive shipping costs | FREESHIP |
Applying a Code
import dash from "@/lib/dash"
// Apply to cart
const { cart } = await dash.cart.applyDiscount("SAVE20")
console.log(cart.discount_code) // "SAVE20"
console.log(cart.discount_amount) // "15.00"
Validating a Code
// Validate without applying
const response = await fetch("/storefront/discount/validate", {
method: "POST",
headers: { "Content-Type": "application/json", "X-API-Key": apiKey },
body: JSON.stringify({ code: "SAVE20", subtotal: "75.00" }),
})
const result = await response.json()
// { valid: true, is_percentage: true, rate: "20", discount_amount: "15.00" }
Creating Codes (Dashboard)
- Go to Marketing → Discounts
- Click Create Discount Code
- Set the code, discount type, and amount
- Optionally set: minimum order amount, max uses, expiration date
- Save
Next Steps
- Affiliate Codes — Affiliate-generated codes
- Bulk Pricing — Quantity-based discounts
- Validate Code — Code validation details
- Apply Discount Code — Using codes in cart