We have daily special deals which I would like to highlight when a user arrives on the page.
As an example: On a Tuesday, a user arrives on the homepage and after about 5 seconds, a lightbox showing Tuesday’s special deal pops up.
I think I understand the logic for the code, but I can’t seem to find the last few things to actually make it work. If someone here can help me, that would be much appreciated! Here is what I have for it. (I would create an IF statement for each day and lightbox).
import wixWindow from ‘wix-window’;
$w.onReady( function () {
var today = new Date(); var day = today.getDay(); var daylist = [“Sunday”, “Monday”, “Tuesday”, "Wednesday “, “Thursday”, “Friday”, “Saturday”];
console.log(“Today is : " + daylist[day] + “.”); if (day === “Wednesday”)
wixWindow.openLightbox(”#Lightbox1”)
});
On a side note, is there a way to change the value for each lightbox? All I can seem to see is each one being named #lightbox1 when selected.
Thank you very much, I was wondering if that was the solution! Appreciate the speedy help.
With my sidenote, I’m unsure about how to reference the specific lightbox in the code. I have about 15 lightboxes and when they are clicked, each one shows up as #lightbox1, which is a little confusing. See below:
Here is one of my lightboxes selected:
Here is a different lightbox selected, but also showing the value as #lightbox1
Both screenshots were taken on the same page, but with a different lightbox open.
As these # values are what I usually use to reference/call an object in the code, I’m unsure how to call a specific lightbox if they all show the same thing?
@admin86183 don’t use the lightbox property id (the “#lightbox1”). This is only the id of the main part of the lighbox (and it’s a local element that only exists inside the lightbox and is not accessible from the web-page itself).
Instead you should use the lighbox name .
For anyone looking for the solution to the question posted here, you can use my code as follows:
import wixWindow from 'wix-window';
$w.onReady(function () {
var today = new Date();
var day = today.getDay();
if (day === 3)
wixWindow.openLightbox("Lightbox Name")
});
In the if statement, it shows day === 3, but you can add whichever day is relevant here. 0=Sunday 1=Monday and so on.
Where ‘Lightbox Name’ is written, insert the name of the lightbox exactly as it appears in the Site Structure Panel (include the spaces if the name uses them).