I have 2 menus for a restaurant, one for the afternoon and one for the evening. I would like to make sure that the lunch menu is shown every day from a certain time and that of the dinner at another time. To do this I thought of creating 2 pages with the menus inside and making an extra page that redirects the user to one of those 2 based on the time the link is opened. how can I do? What codes should I use?
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Hello AdVantage Agency,
yes it is possible to do that. You can do that in different way.
Creating a mainpage, which detects the day-time when page loads.
import wixLocation from 'wix-location'; $w.onReady(() => {start_TimeDetection()}) function start_TimeDetection (parameter) { here you will have your if-query, which will do the right redirection. somehing like .... if myTime === 1 then go page-1 else go page-2 }
You will need this command, to navigate to a specific URL.
wixLocation.to("here your URL")
And because you are using this command you will need the API-reference for it, which you can also find on the top of the code.
import wixLocation from'wix-location';
How exactly to work with DATE & TIME, you can see in this little example here...
https://russian-dima.wixsite.com/meinewebsite/date-time-onclick
There you have also an option to set a TIMER. Isn't it very similar to your needs? 😁
Good luck.
I have a similar situation that I would greatly appreciate ANY help and guidance on - or even the coding. I am not experience with Java either. But with "simple" coding, I can manage to follow to suit my needs.
I'm wanting to do something similar as already discussed in the post and tried modifying the code(s) in this post, without success. Been searching YouTube, contacting Wix, and Velo, etc. for over a month, without being able find what and/or the how for this specific "redirect and back action" I'm needing. This post came pretty close. But still no luck for me.
I'm basically wanting to redirect my customers and visitors to another page within my site (hidden from menu), after 6:PM daily AND THEN stop the redirect at 9:AM the next day - daily. I do understand that I need to use "wixLocation.To", "getTime()" and "if statement" functions. BUT I'm simply at a lost with how to make it work. So still without a solution. 😫
Can anybody help? Please... 😌
Thanks in advance.
It works! Thank you so much for your help! 😀
Awesome, thank you! I'll give it a try.
const data = new Date(); let currentDay = data.getDate(); console.log(currentDay) var menu1Start = '1'; var menu1End = '7'; var menu2Start = '8'; var menu2End = '14'; var menu3Start = '15'; var menu3End = '21'; var menu4Start = '22'; var menu4End = '31'; if (currentDay >= menu1Start && currentDay <= menu1End) { wixLocation.to("/menu-1") } else if (currentDay >= menu2Start && currentDay <= menu2End) { wixLocation.to("/menu-2") } else if (currentDay >= menu3Start && currentDay <= menu3End) { wixLocation.to("/menu-3") } else { wixLocation.to("/menu-4") }
This is the exact code I use to change 4 menus based on the day. You can use the structure too but you will have to use a different Date () because you need the hours from what I understand.
Watch this: https://www.w3schools.com/jsref/jsref_obj_date.asp
It's what I was thinking about using. But I'm very inexperienced with coding, so I was hoping you could tell me if it's correct!
Question, I'm not experienced at all with Java, but I'd like to do something similar. Can you help me??
import wixLocation from'wix-location';$w.onReady(()=>{start_TimeDetection()})functionstart_TimeDetection(parameter){if myTime >1500 then go menu-ih else go menu-ih2}
Would this send customers to my page "menu-ih2" after 3pm?