Managing discounts in Bubble involves creating a Promotion Data Type with rules for discount type, amount, validity period, and conditions. This tutorial covers building the promotion data model, implementing different discount types like percentage off and buy-one-get-one, applying discounts automatically at checkout, managing promotional banners that appear based on active promotions, and tracking promotion usage and effectiveness.
Overview: Discounts and Promotions in Bubble
This tutorial shows you how to build a promotion engine that supports various discount types, applies them at checkout, and tracks their performance.
Prerequisites
- A Bubble app with a product catalog and shopping cart
- Basic understanding of Data Types and Workflows
- Familiarity with conditional logic in Bubble
- A checkout flow where discounts will be applied
Step-by-step guide
Design the promotion data model
Design the promotion data model
Create a 'Promotion' Data Type with: name (text), code (text — for coupon codes), discount_type (Option Set — percentage_off, fixed_amount, buy_one_get_one, free_shipping), discount_value (number — percentage or fixed amount), minimum_purchase (number — minimum cart total to qualify), max_uses (number — total allowed uses), current_uses (number), start_date (date), end_date (date), applies_to (list of Products — empty means all products), is_active (yes/no). Create a 'PromotionUsage' Data Type: promotion (Promotion), user (User), order_id (text), discount_applied (number), used_at (date).
Expected result: A flexible promotion system supporting multiple discount types with usage tracking.
Build the promotion management admin page
Build the promotion management admin page
Create an admin page for managing promotions. Add a form with all Promotion fields, date pickers for start and end dates, and a product selector for targeted promotions. Show a Repeating Group of all promotions with status indicators: green for active (within dates and under max uses), yellow for scheduled (start date in future), red for expired or exhausted. Add edit and deactivate buttons on each row. Include a usage count and revenue impact display for each promotion.
Expected result: Admins can create, edit, activate, and deactivate promotions with clear status visibility.
Implement discount application at checkout
Implement discount application at checkout
In your checkout flow, add a coupon code Input and an Apply button. When Apply is clicked, search for a Promotion where code = input value, is_active = yes, start_date <= current date, end_date >= current date, and current_uses < max_uses. If found, calculate the discount: for percentage_off multiply the cart total by discount_value/100, for fixed_amount subtract discount_value from total, for BOGO add the cheapest qualifying item as free. Validate minimum_purchase if set. Display the discount amount and updated total. Store the applied promotion reference for the order.
Pro tip: Apply discounts to the cart total display immediately but only record the PromotionUsage and increment current_uses when the order is actually confirmed and paid.
Expected result: Customers can enter coupon codes at checkout and see discounts applied to their cart total.
Set up automatic promotions and banners
Set up automatic promotions and banners
For promotions that apply automatically without a code (site-wide sales), search for active promotions where code is empty on cart page load. Apply the best applicable promotion automatically and show a banner: '20% off all items — ends March 31!' Build a promotional banner component that searches for active promotions with a 'show_banner' yes/no field. Display the banner at the top of relevant pages with the promotion details and a countdown timer to the end date. Use conditional visibility so banners only show during the active promotion period.
Expected result: Active promotions apply automatically at checkout and display as banners on relevant pages.
Track promotion effectiveness
Track promotion effectiveness
Build a promotion analytics page. For each promotion, display: total uses (PromotionUsage count), total discount given (sum of discount_applied), total revenue from orders using the promotion, average order value with the promotion vs without, and conversion rate (orders with promotion / total orders during the period). Add a chart showing daily usage over the promotion period. This data helps you understand which promotions drive the most revenue and inform future promotion strategy.
Expected result: Analytics dashboard shows promotion usage, revenue impact, and effectiveness metrics.
Complete working example
1PROMOTION ENGINE SUMMARY2=====================================34DATA MODEL:5 Promotion: name, code, discount_type, discount_value,6 minimum_purchase, max_uses, current_uses,7 start_date, end_date, applies_to, is_active,8 show_banner9 PromotionUsage: promotion, user, order_id,10 discount_applied, used_at1112DISCOUNT TYPES:13 percentage_off: total * (value / 100)14 fixed_amount: total - value15 buy_one_get_one: cheapest item free16 free_shipping: shipping cost = 01718COUPON APPLICATION:19 Input code → Search Promotion20 Validate: active, within dates, under max uses21 Check minimum_purchase22 Calculate and display discount23 Store promotion ref on cart/order2425AUTOMATIC PROMOTIONS:26 No-code promotions: apply automatically27 Search active promotions where code is empty28 Apply best applicable promotion29 Show banner with countdown timer3031USAGE TRACKING:32 On order confirmation:33 Create PromotionUsage record34 Increment Promotion's current_uses35 Analytics:36 Total uses, total discount given37 Revenue with/without promotion38 Average order value comparisonCommon mistakes when managing Discounts and Promotions in Bubble
Why it's a problem: Incrementing promotion usage count before payment is confirmed
How to avoid: Only create PromotionUsage and increment current_uses after successful payment confirmation
Why it's a problem: Not validating promotion dates and usage limits on application
How to avoid: Check all conditions: is_active, date range, max_uses vs current_uses, and minimum_purchase
Why it's a problem: Allowing multiple promotions to stack when not intended
How to avoid: Add logic to clear any previously applied promotion before applying a new one, or explicitly support stacking with clear rules
Best practices
- Validate all promotion conditions before applying discounts
- Track usage only after successful payment
- Display clear discount information at checkout
- Show promotional banners for active site-wide sales
- Include countdown timers to create urgency
- Analyze promotion effectiveness to optimize future campaigns
- Set maximum discount caps to prevent excessive discounting
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to build a coupon code system in my Bubble.io e-commerce app that supports percentage discounts, fixed amount off, and buy-one-get-one. How should I design the data model?
Help me build a promotion system with coupon codes at checkout, automatic site-wide sales with banners, and an admin dashboard showing promotion usage and revenue impact.
Frequently asked questions
Can I have multiple active promotions at once?
Yes. You can have many active promotions, but decide if they can stack. Most stores apply only the best applicable promotion or allow one coupon code per order.
How do I create a time-limited flash sale?
Create a promotion with a short date range (e.g., 24 hours), set show_banner to yes, and add a countdown timer element on your pages. The promotion auto-expires when end_date passes.
Can I target promotions to specific users?
Yes. Add a 'target_users' (list of Users) or 'target_segments' field to Promotion. Check if Current User is in the target list before applying.
How do I prevent coupon code abuse?
Add a 'one_per_user' yes/no field. Before applying, check if a PromotionUsage exists for the current user and this promotion.
Can I schedule promotions in advance?
Yes. Set the start_date to a future date. The promotion will automatically become active when the start date arrives since validation checks the date range.
Can RapidDev help build a promotion engine?
Yes. RapidDev can build complete promotion systems in Bubble including multi-type discounts, targeted campaigns, A/B testing, and analytics dashboards.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation