OpenShopy
Przewodnik

Discounts and promotions

A discount is either a code the customer types (code set) or an automatic promotion (is_automatic: true) that applies whenever its conditions are met.

Types

discount_typevalue meaningExample
percentagePercent off eligible items10 → 10% off
fixedAmount off in minor units of the cart currency, spread across eligible items2000 → 20.00 off
free_shippingIgnored; makes the chosen shipping rate free
bundlePercent off when all bundle_product_ids are in the cart15 → 15% off the bundle items
volumeIgnored; uses volume_tiers [{"min_qty": 3, "percent": 5}, {"min_qty": 10, "percent": 12}]Buy 10+ of eligible items, get 12% off

Conditions

FieldMeaning
applies_toall, products (uses product_ids) or collections (uses collection_ids)
min_subtotalMinimum cart subtotal in minor units
min_quantityMinimum number of eligible items
starts_at, ends_atActive time window
usage_limitTotal number of uses across all customers
usage_per_customerUses per customer email
activeManual on/off switch
combinableWhether this discount can be combined with other discounts

Combination rules

All matching automatic discounts and entered codes are evaluated. Every combinable discount applies; of the non-combinable ones only the single best one for the customer applies. Percentage discounts are capped at 100% and fixed discounts at the eligible subtotal, so a line never goes below zero.

Validating a code

json
POST /discounts/validate
{ "code": "SPRING10", "lines": [{ "variant_id": "…", "quantity": 2 }], "email": "buyer@example.com" }

Returns valid, a human-readable message when invalid (expired, usage limit reached, minimum not met, not applicable…), the applied discount, the resulting discount_total and free_shipping. To apply the code, save it on the cart with PATCH /carts/:token and discount_code.

Reporting

Uses, discount amount given and revenue per code are shown in Analytics, and in report.discounts of GET /analytics/summary.