I wanna show an weekday status into a dynamic page. This will work based on a item showed, in other words, I’m showing one business at time in my dynamic page, so, each one has a week schedule.
I’ve found a site who made a code that I want to make dynamic and show it based on business that displayed on my dynamic page. For example: Business#1 is open just in week days, from 08:00 AM to 18:00 PM, and the code get the user current weekday and hour, and display a status: Is open now or Is closed now.
The website that creates my intended code:
Hi,
Welcome to the Wix Code forums.
You might be able to embed this code in an HtmlComponent . You can read more in the article Working with the HTML Component in Wix Code .
You might get better results by building your own indicator using Wix page components together with the logic provided in the code that you referred to.
Good luck,
Yisrael
Wix already has a awesome app to do this for me(Online Bussines Card, by Appsharp), but I can’t set it dynamically to change with my item page. If has some way to each item shows a diferent content on the app, my problems will be solved
Hi Lista,
It is not possible to interact with third party apps using wix code.
However a system of displaying business hours for multiple businesses can be achieved with some coding:
Start by creating a collection with a list of businesses and their matching business hours.
Each business should go in its own line.
You will have to add fields for: business name, open hour on Sunday, close hour on Sunday, open hour on Monday and etc.
Then simply connect the dynamic page to each field.
To display a ‘Open to business’ message you will have to write a function to retrieve the current day and time and compare it against the relevant collection record opening hours.
Good luck!
Hello @lista-locall I was wondering if you were able to figure this out. Currently trying to build same code based on my dataset of multiple businesses with various hours of operations. I see above not much help was given. Let me know!
Here’s a simple example for displaying if a business is “Open for Business”:
-
View the Live Demo
-
Open the Example in the Editor
Shows how to display if a business is currently “open for business”. Get’s the user’s current date and time, checks if the business is currently open according to the configured business hours, and displays the current status. Also displays the business hours and highlights the current day’s hours.
But what about if you had multiple businesses listed? How can I have it pull from the dataset the times that it is opened and compare to current time?
The business hours are defined in one string. From the example:
let h = new bizHours({ sun: "9:00am-7:00pm", mon: "10:00 am - 3:00 pm,5:00 pm-10:00 pm", wed: "10:00 am-1:00pm,6:00pm-8:00 pm", thu: "9:00 am-5:00 pm" });
You need a businessHours field in your business collection. Then when you do a query, or open a dynamic page for that business, you can query the collection for that field. So, what you would have is:
let bizHoursString = < business hours string from database query >
let h = new bizHours(bizHoursString);
Then just use the rest of the code to determine if the business is open, display the hours, etc.