Available Now filtering option

Hey,

I’m using a custom snippet to try and determine if a listing (service) is available at the time of browsing in order to render a custom badge. However, I’ve dreamt up a secondary part that I’d like to layer on top of this, which would be the ability to filter listings by their ‘Available Now’ status.

Could you please provide guidance on how to add a new filtering option manually (with code), so I can attempt to combine my existing logic check with the new filtering option.

It would also be really nice if HivePress had an ‘available now’ filtering logic built in by default. (I’m not sure whether to post this in general or feature requests.)

Many thanks in advance!

Cheers,
Chris :victory_hand:

Hi,

Could you please clarify what available means in this case? Should it be based on opening hours, booking from — to, or other criteria?

Hey @kseniia,

In my use-case, I’m using a snippet that I crafted with the help of AI using some guidance previously given by Ihor, that essentially checks:

  • The current day is marked as available in a vendor’s calendar.
  • The current time falls within a vendor’s set working hours.
  • There are no overlapping bookings.
  • The date hasn’t been blocked in a vendor’s availability calendar.

If all of these return true, I regard the listing as available.

Cheers,
Chris :victory_hand:

Thanks for the details.

Unfortunately, it looks like this might need a complex SQL query due to the combination of multiple criteria. You can check the hook hivepress/v1/models/listing/search, which allows you to modify the search SQL query and add meta/taxonomy filters [since a listing is a post type, it’s basically a standard WP_Query object].

Hope this helps.