I came across the project on X today. I could really use this for an upcoming project I have. The only thing I'm currently missing is discounts, and I would like to add those here. I've written down a basic plan on what I'm looking forward to adding. Let me know if you'd like any changes.
Aim: Add support for discount codes for carts (percentage, fixed amount, free shipping).
discounts table
- id – text, primary key
- store_id – text, not null, foreign key → stores(id)
- code – text, unique
- type – text, not null, enum (percentage, fixed_amount, free_shipping)
- value – integer, not null
- status – text, not null, default active, enum (active, inactive)
- min_purchase_cents – integer, default 0
- max_discount_cents – integer, nullable
- starts_at – text, nullable
- expires_at – text, nullable
- usage_limit – integer, nullable
- usage_count – integer, not null, default 0
- stripe_coupon_id – text, nullable
- stripe_promotion_code_id – text, nullable
- created_at – text, not null, default now
- updated_at – text, not null, default now
discount_usage table
- id – text, primary key
- discount_id – text, not null, foreign key → discounts(id)
- order_id – text, not null, foreign key → orders(id)
- customer_email – text, not null
- discount_amount_cents – integer, not null
- created_at – text, not null, default now
I came across the project on X today. I could really use this for an upcoming project I have. The only thing I'm currently missing is discounts, and I would like to add those here. I've written down a basic plan on what I'm looking forward to adding. Let me know if you'd like any changes.
Aim: Add support for discount codes for carts (percentage, fixed amount, free shipping).
API
GET|POST|PATCH|DELETE /v1/discountsPOST /v1/carts/:id/apply-discount,DELETE /v1/carts/:id/discountDiscount flow
allow_promotion_codes)Types of discount
DB changes
discountsanddiscounts_usageMisc