Filter examples

A list of examples to help you understand how to combine filters when requesting /findtime

d
Written by derrick mak
Updated over a week ago

These examples will help you configure your filters so that your particular business-rules are implemented. These examples are based on the assumption that you manually configure either your API calls or the bookings.js widget. You can configure filters on your projects for use in the booking.js widget in our admin panel, but if you need more complex configurations you need to set this up manually.

Common working-hours

Commonly working-hours are 9-18 monday to friday, this can be configured like this:

"filters": { "and": [
  {"working-hours":{}},
  {"exclude-weekend":{}}
]}

If you have non-common hours, like 17-21 you should use the specific time filter like so:

"filters": { "and": [
  {"specific-time":{"start":17,"end":21}},
  {"exclude-weekend":{}}
]}

Only specific days

If your business-rules demand only specific days, like Wednesdays and Thursdays 8-14 you should use "or" filters, because "and"'ing Wednesdays and Thursdays will rule everything out because a time-slot is never both Wednesday and Thursday. So this would be the filter you should employ:

"filters": { 
  "or": [
    {"specific-day": "Wednesday"},
    {"specific-day": "Thursday"},
  ],
  "and": [
    {"specific-time":{"start":8,"end":14}}
  ]
}

Special hours on specific days

If each day has its own specific hours, you should use specific day and time filters like this:

"filters": { 
  "or": [
    {"specific_day_and_time":{"day":"Monday","start":10,"end":12}},
    {"specific_day_and_time":{"day":"Tuesday","start":14,"end":18}},
    {"specific_day_and_time":{"day":"Wednesday","start":10,"end":18}},
    {"specific_day_and_time":{"day":"Thursday","start":10,"end":16}}
  ]
}

Specific dates

This is a way of adding only specific dates as available. Here we make May 29th, April 9th and July 4th the only dates available.

"filters": { 
  "or": [
    { "between_timestamps": {
        "start":"2017-05-29T00:00:00+01:00",
        "end":"2017-05-30T00:00:00+01:00"
    }},
    { "between_timestamps": {
        "start":"2017-04-09T00:00:00+01:00",
        "end":"2017-04-10T00:00:00+01:00"
    }},
    { "between_timestamps": {
        "start":"2017-07-04T00:00:00+01:00",
        "end":"2017-07-05T00:00:00+01:00"
    }},    
  ]
}


For a complete reference of filters please refer to our API reference.

Did this answer your question?