I’m making a car rental marketplace, which allows my users to find a car rental, choose a car and rent it, all online within 5 minutes. The map must show only open car rentals, so my users don’t try to rent a car in a closed car rental. I’ve spent some hours trying to figure it out and I’m gonna be sooo glad if y’all could help, thx!
Just set your map datasource to only rentals that are open…
Thanks for the answer, but I’m not getting the rentals directly from Google Maps, the ones that appear on my map are rentals that I register in the database. How would I register the opening hours of each one in the database and make the map understand that the rentals should only be displayed when they are within these opening hours?
Yeah, I assumed they were coming from your database… hence my answer to just add the appropriate search constraints to only show rentals that are open…
Obviously, how you do that depends on how your database is set up…
One simple way (this will only work if the opening times are the same for each day they are open), is just to have a list of numbers field to determine which days of the week they are open (each day represented as a number, 0-6), and then 2 additional number fields to store the opening times, Opening Time and Closing Time (each represented as a decimal Hour… e.g. if they open at 9:30am, the number would be 9.5 and if they close at 5:30pm it would be 17.5)…
The you can simply use the following constraints on your search:
Open Days Contains Current Date/Time: Extract Day
Open Hour ≤ Current Date/Time: Extract Hour + (Current Date/Time: Extract Minute/60)
Close Hour > Current Date/Time: Extract Hour + (Current Date/Time: Extract Minute/60)
If each day has different opening times, then it will be a bit more complicated… you’ll probably have to create a new datatype to store the Opening times for each day, for each branch…
Also note that the Current Date/Time is only defined once, when the search is done, so if you want the map to update in real time as and when branches open or close, you’ll need to address that, by somehow updating the Current Date/Time every second to stay up to date…
There are various ways you can do that (either with Vanilla Bubble, a plugin, or some simple JavaScript…) - there are numerous forum posts about this… so have a search through if you need some guidance.
Great! Thanks sooooo much my friend, I understood perfectly your explanation, but I’m still with one little doubt.
I created the list of numbers field exactly like you said, but how it’ll understand which day of the week each number represents? Number zero is equal to Monday, number one is equal to Tuesday and so on?
0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday
Ahhh ok, I didn’t know about this. Thank you so much Adam!