> ## Documentation Index
> Fetch the complete documentation index at: https://codebeans-discount-engine-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# How it works

> The two halves of every campaign: the discount function and the storefront display.

A campaign has two halves:

1. **The discount function** applies your discount in the cart and at checkout. It runs as a Shopify Function on Shopify's own infrastructure.
2. **The theme blocks** display the offer on your storefront, so shoppers see it before they add to cart.

You only need the first half for a discount to work. The second half is what turns a working discount into one that changes what shoppers put in their cart.

## From campaign to checkout

```mermaid theme={null}
flowchart LR
  A[You build a campaign in the app] --> B[App saves a Shopify discount with its configuration]
  B --> C[Shopper's cart reaches checkout]
  C --> D[Discount function checks qualifiers and eligibility]
  D --> E[Discount applied to products, order or shipping]
```

When you save a campaign, the app creates a Shopify **automatic** or **code** discount and stores your configuration with it. At checkout, Shopify runs the discount function, which checks your qualifiers and eligible products against the live cart and returns the discount.

Because each campaign is a real Shopify discount, it also appears under **Discounts** in your Shopify admin, and Shopify's combination settings decide how it stacks with other discounts. See [Combinations and strategy](https://codebeans-discount-engine-pro.mintlify.site/campaigns/combinations.md).

## Status comes from dates

A campaign's status is derived from its dates; you never set it directly.

| Status | When |
| - | - |
| Scheduled | The start date is in the future |
| Active | The start date has passed and the end date has not |
| Expired | The end date is in the past |

Shopify is the source of truth for status, which is why **Activate** and **Expire** move the dates rather than flipping a switch. See [Activating and expiring](https://codebeans-discount-engine-pro.mintlify.site/managing/activate-and-expire.md).

## Configuration size

Shopify limits how much configuration one discount function can carry. The campaign form shows a **Function's limit** meter while you build.

> [!WARNING]
>
> Keep the meter under 80%. If a discount is getting close to the limit, move some of its campaigns into a second discount.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.