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.
Create and manage percentage and fixed-amount coupons.
Updated
Discount codes allow customers to get price reductions at checkout. Codes are created and managed in the dashboard.
| 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 |
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"
// 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" }