Hi there, i'm trying to create a directory with restaurants where the user
1) should be able to filter by post code in order to see what restaurants will deliver to his area/post code.
2) search results should be divided in two sections, the restaurants that deliver to his/her post code and are currently open and the restaurants that deliver but are currently closed or available only for takeout at the moment.
Number 1 is definitely my priority for the moment. Can you please advice what is the best way to achieve this using toolset?
Thanks,
Stelios
Hello, one way to accomplish this is to use a multiple-instance single-line custom field.
- Create a single-line custom field "Postal Codes" and choose the option "Allow multiple-instances of this field". Apply this field to the restaurant post type.
- When you create or edit a Restaurant post, add all the postal codes they serve in the postal codes field.
- In a custom search View, you can filter by postal code using a text field.
Let me know if you have questions about this approach, or if I misunderstood what you want to achieve.
Hi Christian,
thank you so much for the reply.
How about this one ? Any ideas?
"Search results should be divided in two sections, the restaurants that deliver to his/her post code and are currently open and the restaurants that deliver but are currently closed or available only for takeout at the moment."
This isn't as straightforward. Toolset doesn't have a built-in timeline availability feature like this, unfortunately, and it sounds fairly complex since you would need to be able to manage the start and end times for multiple schedules (takeout, delivery, dine-in) for each restaurant on each day of the week.
Once you have determined how you want to handle that information management, you would have to programmatically modify the query for each search based on the current day and time. We offer the wpv_filter_query API to help you programmatically modify queries like this:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
You could use two Views to display this information in different sections. The first View could contain the filters and the results (delivery available results), and the second View could contain just the results (delivery not available results). In this case, AJAX would not be supported.