@haircrafterjo
I just wanted to see how you setted-up your project, that means, which elements you are using, if you already have prepared a database, like mentioned/suggested by Yisrael?
If it comes to the following question:
Hi,
I develop a website for guests staying at a particular guest house.
I want the customer to receive a link to the site on the day of arrival and for the site to be available for him until the day of departure.
Of course every time the link has to be different.
Is there anything that can be done using Wix code?
Maybe an idea for an option outside of Wix?
Yes this should be feasible/possible. Also your wished function is possible to be done.
How i would proceed in your situation?
- First i would ask myself - → What do we have, what is my initial situation?
- Which elements am i using?
- What do i want to create?
- And how would be the flow of my project/function?
So let’s say we have a button on our page, which activates your mentioned → FREE-OFFER-FUNCTION. You click on the button another button appears, or you are redirected to another (hidden) page, there could be be different cases , how to manage this first step.
After sthis step has been done, your function should be activated, that means after theis first activating click → your 24-hours timer starts! HOW?
Like Yisrael mentioned, you will need a DATABASE for this, to be able to save the DATE and TIME of the proceeeded CLICK in your DB. Once you have saved the current date & time of the click a timer is running.
But how do the timer running? → It’s simple! Since you want to disable/disapear/hide the button after 24-hours again, you can set at the same time when you set the date & time - - → a SECOND date and time in a second row (called expirationDate/Time), but before you save the second date&time in the second row, you add to the expiration-date → (+24hours) and save it in your “expirationDate” column of your database.
Now you have two saved DATES → startDate & expirationDate.
Working with dates and times is not that easy and can create confusions very quick when working with them.
But if you always keep in mind that dates & times are calculated in → milliseconds
WHAT - - → MILLISECONDS ?
YES → MILLISECONDS , then you will have an easy game.
Perhaps reading this post here, also will help you…
So to make it short…
Set a → time-stamp of current date.
Add the milliseconds of 24-hours to the setted time-stamp…
…and you will get your expiration-date.
let timeStamp = new Date().getTime(); console.log(timeStamp)
let expirationDate = new Date(timeStamp+1000*60*60*24); console.log(expirationDate);
$w.onReady(async function() {
let timeStamp = new Date().getTime(); console.log(timeStamp);
let expirationDate = new Date(timeStamp+1000*60*60*24); console.log(expirationDate);
});
And the rest is pure - - → logic + perhaps in addition the following link…
BTW: These were your 24-hours → 10006060*24
Good luck!