Behio Storefront SDK
Cart & Checkout

Discounts & Gift Cards

Apply discount codes and gift cards to the cart

Discount Codes

Apply

const cart = await client.cart.applyDiscount('SUMMER20');

Remove

const cart = await client.cart.removeDiscount();

Discount Types

TypeDescription
PERCENTAGEPercentage off subtotal (e.g. 20%)
FIXED_AMOUNTFixed amount off (e.g. 100 CZK)
FREE_SHIPPINGFree shipping

Discounts are validated server-side: expiration, usage limits, minimum order amount.

Additional shipping benefit (SDK 2.23)

cart.discount.shippingDiscountType is PERCENTAGE, FIXED_AMOUNT, FREE_SHIPPING, or null/absent. shippingDiscountValue is its percentage or fixed amount. This benefit is separate from the merchandise discount, so a code can give 10% off products and 50% off shipping. A zero merchandise percentage with a delivery benefit is a shipping-only code. Existing type: FREE_SHIPPING codes continue to work.

A fixed delivery benefit uses the discount currency. Eligibility and usage limits apply to the whole code; shipping cannot become negative. An automatic free-shipping promotion does not stack a second delivery deduction. maxDiscountAmount caps the merchandise percentage discount; the additional shipping benefit is capped separately by the delivery price.

Render the benefit description, but do not subtract it from cart totals yourself. Shipping is calculated after the delivery choice. Use checkout.preview and its authoritative totals, and refresh the preview after any delivery or cart change. Older API responses may omit these fields.

Gift Cards

Check Balance First

const { valid, balance, currency } = await client.catalog.checkGiftCard('GC-ABCD-EFGH-IJKL');

Apply to Cart

const cart = await client.cart.applyGiftCard('GC-ABCD-EFGH-IJKL');
// A cart can hold several gift cards, call applyGiftCard again with another code.
cart.giftCards; // [{ code, balance, currency }, ...] applied cards + balances

Remove

// Remove one specific applied card by its code.
const cart = await client.cart.removeGiftCard('GC-ABCD-EFGH-IJKL');

Multiple gift cards can be applied to one cart. At checkout they are consumed in the order they were added, and each covers min(its balance, the remaining due), so the last card is spent partially and its leftover balance stays on the card. Balances are deducted atomically; concurrent checkouts cannot double-spend.

Combining Discounts

You can combine a discount code and a gift card on the same order. The discount is applied to the subtotal first, then the gift card covers the remaining amount.

On this page