> For the complete documentation index, see [llms.txt](https://docs.peakcommerce.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peakcommerce.com/developers/logic-and-rules/logic-and-rules.md).

# Overview

PeakCommerce applies business logic through several **separate, purpose-built engines** rather than one general-purpose rule system. There is no single "if this, then that" builder that can express any rule you can imagine. Each engine owns one job, has its own configuration surface, and runs at a specific point in a flow.

Knowing which engine owns which job is the whole skill. Most of the time a requirement that sounds like "we need a rule for X" maps cleanly onto exactly one of them.

## The engines

| Engine                | Owns                                                                                                                | Configure under                     |
| --------------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| **Business Rules**    | *When* a subscription change takes effect, how it prorates, whether it co-terms, and whether it is blocked outright | Rules & Automation → Business Rules |
| **Plan Dependencies** | Keeping one charge's quantity in step with another's                                                                | Commerce → Catalog                  |
| **Pricing Rules**     | Adjusting price — percentage discount or markup, fixed override, or tiered                                          | Rules & Automation → Pricing Rules  |
| **Policy Engine**     | Hard ceilings no channel may exceed, such as a maximum discount or a seat limit                                     | Rules & Automation → Policies       |
| **Territory Rules**   | Which accounts a CSR or partner can see and act on                                                                  | Settings → Profiles                 |
| **Product Sets**      | Which plans and add-ons are offered, and how they constrain each other                                              | Commerce → Product Sets             |

## What a Business Rule can and cannot do

Business Rules are the most commonly misunderstood engine, so it is worth being precise. A business rule matches on a **direction** — upgrade, downgrade, cancellation, add-on, or remove add-on — optionally scoped to products, categories, plans, or audiences, and optionally limited to the customer or CSR surface.

When it matches, it can do exactly four things:

* set the **change timing** (immediate, end of term, custom delay, grace period, next chargeable period, or paying-plan activation),
* set the **proration** (full, prorated, or none),
* **co-term** the change to the base subscription,
* or **block** the change entirely.

That is the complete vocabulary. A business rule cannot show or hide a journey step, cannot remove a product from a cart, cannot raise a custom message, and cannot run arbitrary logic. Requirements of that shape belong to a different engine — see the recipes below.

Rules do not carry a priority number. When several match, the most specific one wins: audience and plan beats audience and product, which beats plan, then product, then category, then an audience-wide rule, then a tenant-wide default. A rule scoped to a specific surface edges out an equally specific rule that applies to any surface, and if two rules are still tied, the most recently updated one is used.

## Recipes

* [Match quantity across plans](/developers/logic-and-rules/logic-and-rules/rule-match-quantity.md) — keep one charge's quantity in step with another.
* [Hide plans based on existing subscription products](/developers/logic-and-rules/logic-and-rules/rule-hide-plans-based-on-existing-subscription-products.md) — show a customer only the plans that make sense for what they already own.
* [Plan selection and deactivation](/developers/logic-and-rules/logic-and-rules/rule-plan-selection-and-deactivation.md) — require or exclude add-ons based on what else is selected.
* [Raise an error](/developers/logic-and-rules/logic-and-rules/rule-raise-error.md) — stop a flow with a message you write.
* [Enforce product quantity](/developers/logic-and-rules/logic-and-rules/rule-enforce-product-quantity.md) — cap how many units an order may contain.
* [Automated product removal](/developers/logic-and-rules/logic-and-rules/rule-automated-product-removal.md) — drop selections that are no longer valid.

## Related

* [Rules Overview](https://gitlab.com/peak-hercules/peak-help-docs/-/tree/main/product/rules-and-customizations/rules-overview/README.md) — the same engines described for administrators.
* [Creating and Managing Rule Sets](https://gitlab.com/peak-hercules/peak-help-docs/-/tree/main/product/rules-and-customizations/rules-overview/creating-and-managing-rule-sets.md) — the Business Rules form, field by field.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.peakcommerce.com/developers/logic-and-rules/logic-and-rules.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
