Discounts¶
File: app/core/models/discounts.py
Stores campaign discount metadata synced from Shopify.
Key fields¶
| Field | Description |
|---|---|
id, name, description |
Identity |
provider / provider_id |
Shopify enum / Shopify discount ID |
discount_type, value |
e.g., percentage, fixed amount |
json |
Metadata: prefix for code generation, product/collection IDs, purchase_type, minimum_spend |
code_count |
Tracks generated codes |
Assignment flow¶
- Creation: POST
/v1/discounts/syncs with Shopify, stores in DB - Campaign linking: Campaigns store
discount_id,discount_code(static), anduse_unique_discountflag - Recipient assignment (
methods/runner.py:apply_discount_code()): - Static: Applies campaign-level
discount_codeto all recipients - Unique: Generates per-recipient codes from Shopify, stores in
recipient.json["discount_code"], incrementscode_count
Attribution integration¶
methods/attributions.py:check_recipient_order_discount_match() compares recipient's discount code with order's discount codes (case-insensitive). If matched, attribution automatically passes rules regardless of timing window.
Key files¶
- Model:
core/models/discounts.py - Routes:
routes/discount_routes.py - Assignment:
methods/runner.py - Attribution:
methods/attributions.py