Skip to main content

ApplyPromoCode

Need storefront configuration?

Use the public API origin, merchant slug, and location ID. Storefront components never receive a Crave API key; register each exact browser origin before making requests.
A compact input with an apply button that lets customers enter and validate promotional discount codes during checkout.

Preview

Import

Usage

Props

(code: string) => Promise<PromoResult>
required
Async callback to validate and apply the promo code. Should return the discount result or throw on invalid codes.
string
Currently applied promo code, if any.
() => void
Callback to remove the currently applied promo code.

Behavior

  • Inline validation with loading state during API call
  • Shows success message with discount amount on valid code
  • Shows error message for invalid or expired codes
  • Displays applied code as a removable chip
  • Collapses to “Have a promo code?” link when no code is applied