# 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.

***

![](/files/srpikMFEEji0CJDBF7Pf)

***

### 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.

***

![](/files/fzqfhGozfAtcIT48SUcd)

***

### 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.

***

![](/files/uUixvni5n62NY22U0tjV)&#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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.adalo.com/how-to/applying-coupon-codes-in-adalo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
