Trigger Different Lightboxes According to Time of Day

Hi,

I would like to display a different lightbox according to the time of day a user is on the website. For example, I would like to display a breakfast special until 10:30 am, a lunch special from 10:30 to 1:30 pm, and an afternoon wine special from 1:30 to 4:00 pm.

Can somebody outline a script I could modify for this purpose. I am brandnew to both Wix and Corvid.

Many thanks.

Ted

So first of all find the the hour:

let currentHour = new Date().getHours();

then create a condition set:

switch(true){
case (currentHour >= 0 && currentHour < 8):
    wixWindow.openLightbox("A");
    break;
case (currentHour >= 8 && currentHour < 12):
    wixWindow.openLightbox("B");
    break;
//etc...
}

Hi,

I set this up as a function on the Home page. I am getting an error message “wixWindow is not defined”. How do I do that?

Many thanks!

Ted

You need to have it in your imports at the top of your page.
import wixWindow from ‘wix-window’

See here for more info with code samples
https://www.wix.com/corvid/reference/wix-window.html#openLightbox

Plus, have you changed the lightbox names from the sample of A and B to the actual names of your own lightboxes used instead.