# Applying Coupon Codes in Adalo

###

{% embed url="<https://www.youtube.com/watch?v=lXEaBXz6Ca0>" %}

### Purpose

This document explains how to build a coupon code system in Adalo that supports:

* Fixed dollar discounts (e.g. $5 off)
* Percentage-based discounts (e.g. 10% off)\ <br>

The solution uses native Adalo features only—no custom actions, external APIs, or third-party tools.

***

### What This System Supports

* Validating coupon codes entered by users
* Applying discounts dynamically at checkout
* Supporting both fixed and percentage discounts
* Removing or changing coupons without leaving checkout
* Using the same logic across carts, orders, or subscriptions

***

### High-Level Flow

1. Coupon codes are stored in a database
2. Users enter a coupon code at checkout
3. Adalo validates the code using a filtered list
4. The discount is calculated and stored on the logged-in user
5. Totals are recalculated automatically\ <br>

***

### Step 1: Create the Coupon Codes Collection

Create a new collection named:

Coupon Codes

#### Required Properties

| Property Name  | Type         | Purpose                                     |
| -------------- | ------------ | ------------------------------------------- |
| Name           | Text         | The coupon code users type (case-sensitive) |
| Amount Off     | Number       | Dollar amount or decimal percentage         |
| Is Percent Off | True / False | Identifies discount type                    |

***

#### Coupon Value Rules

Fixed Discount Example

* Coupon: $5OFF
* Amount Off: 5
* Is Percent Off: false

Percentage Discount Example

* Coupon: 10OFF
* Amount Off: 0.1
* Is Percent Off: true

💡 Tip:\
Store percentages as decimals.\
10% = 0.1, 20% = 0.2, etc.

***

![](https://3467607506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LhGHkPsv15svPIU5I7C%2Fuploads%2FBKUZQJ5TMB4d7MluYSoK%2Funknown.png?alt=media\&token=e3efeeec-1974-4aec-8cfa-6624c597256c)

***

### Step 2: Add Coupon Input to Checkout Screen

On your checkout or payment screen:

#### Add a Text Input

* Label: Coupon
* Purpose: User enters the coupon code

#### Add a List

* Collection: Coupon Codes

Filter:\
Name = Coupon Input

#### Optional Visibility Rule

Coupon Input is not empty

<br>

💡 Why this matters\
This prevents invalid coupons from appearing and hides UI when no code is entered.

***

![](https://3467607506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LhGHkPsv15svPIU5I7C%2Fuploads%2FLj3eN3k0g6hPccCcewi0%2Funknown.png?alt=media\&token=a103941f-44ae-4aca-be8c-efac431868dc)

***

### Step 3: Add an Apply Coupon Button

Inside the Coupon Codes list, add a button:

* Label: Apply
* (Optional) Show the coupon name for testing/debugging\ <br>

This button will trigger the discount logic.

***

### Step 4: Create the Coupon Amount Property

On the Logged-In User collection, create a number property:

Coupon Amount

This property stores the actual dollar value of the discount, regardless of coupon type.

***

### Step 5: Fixed Amount Discount Logic

#### Button Action

Update Logged-In User

#### Only Run If

Is Percent Off = false

#### Set Value

Coupon Amount = Amount Off

Example

* $5 off → Coupon Amount = 5\ <br>

***

### Step 6: Percentage Discount Logic

Percentage discounts must be converted into a dollar amount.

#### Button Action

Update Logged-In User

#### Only Run If

Is Percent Off = true

#### Formula

Coupon Amount = Amount Off × Cart Subtotal

Example

$9.00 × 0.1 = $0.90

<br>

⚠️ Important\
Always calculate the percentage against the subtotal before tax.

***

![](https://3467607506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LhGHkPsv15svPIU5I7C%2Fuploads%2FNTq6E8RyTbxQL4a8vJKZ%2Funknown.png?alt=media\&token=d0555853-e640-4c06-abc5-16ee2f256315)&#x20;

***

### Step 7: Show Coupon in Checkout UI

Use conditional visibility to keep the UI clean.

#### Visibility Rule

Coupon Amount > 0

<br>

#### Display Elements

* Coupon label
* Discount value (shown as a negative amount)
* Optional “Remove Coupon” button\ <br>

***

### Step 8: Remove Coupon Option

Add a small X or Remove Coupon button.

#### Click Action

Update Logged-In User

Coupon Amount = 0

#### Visibility Rule

Coupon Amount > 0

This allows users to remove a coupon without restarting checkout.

***

### Step 9: Update Subtotal & Total Calculations

#### Subtotal Formula

Subtotal = Cart Subtotal − Coupon Amount

#### Total Formula

Total = (Cart Subtotal − Coupon Amount) + Tax

This logic works for:

* Single-item carts
* Multi-item carts
* Add-ons
* Persistent user carts\ <br>

***

### Best Practices & Notes

* Coupon codes are case-sensitive
* Store the coupon value on the logged-in user for easy access
* Admins can manage coupons directly in Adalo
* This pattern works without custom actions or external tools\ <br>

***

### Summary

This setup allows you to:

* Validate coupon codes natively
* Support both fixed and percentage discounts
* Apply coupons dynamically at checkout
* Keep all logic inside Adalo\ <br>

It’s flexible, scalable, and production-ready.

<br>
