---
title: "Prevent product purchases if a booking is shorter than a set amount of time"
slug: "prevent-product-purchases-if-a-booking-is-shorter-than-a-set-amount-of-time"
updated: 2024-03-14T10:49:13Z
published: 2024-03-14T10:49:13Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://help.nexudus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prevent product purchases if a booking is shorter than a set amount of time

This rule prevents the purchase of a specific product alongside a booking if the booking is shorter than a minimum duration you define.

*For example, customers booking any resource for less than 2 hours cannot purchase the catering service that you sell as a product alongside the resource.*

You need the following details to set up this rule:

- **The ID of the product that can't be purchased if bookings are too short.**

          Don't know where to get this ID?

          

Check out [Finding Product IDs](/v3/docs/finding-product-ids).

---

1. Log in to [dashboard.nexudus.com](https://dashboard.nexudus.com/) if you aren't already.
2. Click [**Settings > Validation rules**](https://dashboard.nexudus.com/settings/3/0/0).
3. Click **Add rule**.
4. Click on **Manual entry**.
5. Name your validation rule.
6. Add a **Description** for your rule to let other admins know what it does at a glance.
7. Toggle on **This rule is active**.
8. Select **Bookings** in the **Record type**.
9. Add the **Error message to display if the validation rule is not met**.
10. Add the following code snippet to the **Formula** field.

```
(record.GetLengthInMinutes() >= MINUTES) OR (HasProduct(record, PRODUCT_ID) = false)
```

1. Replace **MINUTES** in the formula with the minimum booking length to allow the purchase of the selected product.

          The minimum booking length is always defined in **minutes**.

          

*In the example below we used 2 hours or 120 minutes.*

(record.GetLengthInMinutes() >= **120**) OR (HasProduct(record, PRODUCT_ID) = false)

1. Replace **PRODUCT_ID** in the formula with the ID of the product that can't be purchased if bookings don't meet the mimimum length defined in the previous step.

*In the example below, the product ID is 123456789.*

(record.GetLengthInMinutes() >= **120**) OR (HasProduct(record, **123456789**) = false)

1. Click the **Save Changes** button.

---

All done! We recommend trying to purchase the selected product alongside a booking that is shorter than the minimum booking duration you defined. If you see your error message displayed as you try to check out, you're good to go.
