Prevent product purchases if a booking is shorter than a set amount of time
  • 28 Sep 2022
  • 1 Minute to read

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


Article Summary

This rule prevents the purchase of a specific product alongside a booking if the booking is shorter than a minimum length 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 our tutorial on Finding Product IDs.


  1. Log in to the Admin Panel if you aren't already.

  2. Click Add rule

  3. Click on Manual entry

  4. Name your validation rule.

  5. Add a Description for your rule to let other admins know what it does at a glance.

  6. Enable the This rule is active toggle.

  7. Select Bookings in the Record type.

  8. Add the Error message to display if the validation rule is not met.

  9. 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 products.
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 you test your validation rule by trying to purchase the selected product alongside a booking that is shorter than the minimum booking length defined in your rule. If you get the error message you've defined, your rule is ready to go!