# Cart and checkout validations

Cart and checkout validation lets you control when a customer can proceed to checkout by applying custom rules to their cart.&#x20;

For example, you can require a minimum spend of $20, prevent checkout if a restricted item is in the cart for certain regions, or limit the total number of items purchased. This feature is useful for enforcing shipping restrictions, setting purchase limits, or applying order rules without impacting every customer.

## In this section:

* [Creating a cart & checkout validation function](#creating-a-cart-and-checkout-validation-function)
  * [Example of a cart & checkout validation function](#example-of-a-cart-and-checkout-validation-function)

***

## Creating a cart & checkout validation function

### Step 1 of 3:

1. From the Function Junction dashboard, click **Create new campaign**.
2. Under **Create campaign**, click **Start from scratch.**
3. Beside **Cart & Checkout Validation**, click **Continue**.
4. Under **Function name**, give your discount a unique name so you can identify it later.
5. Under **Condition type**, click the drop-down and select one of the following:
   1. **Standard:** The most commonly used and well-balanced settings.
   2. **Delivery:** For conditions that are more related to shipping and delivery.
6. Click **Next.**

### Step 2 of 3:

1. Define the condition that activates the function:
   1. From the drop-down menu, select the condition that you want the cart validation to be based on like `cart subtotal is greater than $15`&#x20;
   2. Optional: Click **Add a condition** to add any additional conditions that you want.
   3. Click **Next.**

### Step 3 of 3:

1. Define the error messages to be displayed to the customer when the condition is met.&#x20;
   1. Under **Customer flow**, click the drown-down menu and select the condition that triggers the cart validation error message.
   2. Under **Error message**, enter the message that you want to display to customers.
   3. Under **Display location**, click the drop-down menu and select where you want the message to be displayed to the customer.
2. Optional: If you want to add additional error messages for different locations, click **Add error message** and repeat steps 1a through 1c.

***

### Example of a cart & checkout validation function

In this example, Akio wants to set up a minimum order value of $50 required for customers to check out.

* **Function name**: In this case, Akio would give his cart validation function a name like `Minimum spend cart validation` so that he can identify it later.
* **Condition type**: Since he wants this to apply to a minimum spend, not related to delivery, he would leave the condition type set to **Standard**.
* **Conditions**: In step 2, because he wants this to be exclusive to carts with at least $50 worth of product he needs to add the condition:
  * `if` `cart subtotal` `is less than` `$50`
* **Error messages**: In step 3, Akio would enter the error messages he wants to present customers when they reach certain stages of the checkout.&#x20;
  * **Customer flow:** He wants the error message to come up any time during customer interaction with the cart or checkout process, so he leaves **Customer flow** set to `All`
  * **Error message:** He wants the error to read `Unable to complete checkout, cart total needs to meet $50` so he would add this message under **Error message**.
  * **Display location:** He wants the error message to be displayed in the customer's cart so he leaves the **Display location** set to `Cart`.&#x20;


---

# 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://support.functionjunctionapp.com/function-types/cart-and-checkout-validations.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.
