- 14 Mar 2024
- 1 Minute to read
- DarkLight
Prevent product purchases if a booking is shorter than a set amount of time
- Updated on 14 Mar 2024
- 1 Minute to read
- DarkLight
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.
Check out Finding Product IDs.
Log in to dashboard.nexudus.com if you aren't already.
Click Settings > Validation rules.
Click Add rule.
Click on Manual entry.
Name your validation rule.
Add a Description for your rule to let other admins know what it does at a glance.
Toggle on This rule is active.
Select Bookings in the Record type.
Add the Error message to display if the validation rule is not met.
Add the following code snippet to the Formula field.
(record.GetLengthInMinutes() >= MINUTES) OR (HasProduct(record, PRODUCT_ID) = false)
- Replace MINUTES in the formula with the minimum booking length to allow the purchase of the selected product.
In the example below we used 2 hours or 120 minutes.
(record.GetLengthInMinutes() >= 120) OR (HasProduct(record, PRODUCT_ID) = false)
- 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)
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.