Hello, I got this script for displaying random numbers. Debug URL: Controllable LED Curtain – TrendBlend
I added it to my main-product.liquid but I am facing a problem. The localStorage appear different from mobile than desktop. And I’m also having another problem, the numbers update on phone. But the numbers only update on desktop after refreshing, so not when the number is actually updated (after 3000ms)
Hello @TrendBlend ,
Javascript is client side language, its run when page load.
Okay, thanks for your reaction, so it is not really possible to store the data in like a map and update the map every x seconds/minutes to always show the same number to different users/devices? And if it is not, do you maybe know why the numbers are not changing on desktop, but are changing on phone for this code?
Kind regards,
Stef
You are not a good explainer please explain me in detail actually what you want to do? secondly if you have any referance link kindly share.
Hello @iffikhan30 ,
I want to show a random number for units sold in the last 24 hours and how many people are looking at the product right now. This number has to stay between the minimum and maximum which is settled with this code:
minSold: 3, maxSold: 9, minViews: 4, maxViews: 16, for example. So for this code something like this would show:
5 sold in the last 24 hours.
12 people are looking at this product right now.
currently I am using localstorage which shows other numbers to different people at the same time. But also has the issue that when the same person looks on mobile the code outputs different numbers than when he looks on desktop. This would mean that he sees 3 units sold on mobile and 8 units sold on desktop AT THE SAME TIME. This is a problem, because the number should always show the same at a time. So for desktop and mobile the number should both show 3 units sold in the last 24 hours, but this number should be able to change (which is what the interval does). This does not only need to work for different devices but also for different users. So when one user is seeing 3 units sold, it should not be possible that another user sees 5 units sold at the same time. So the random numbers have to update at the same time for everyone, and not xx seconds (or minutes) after the code is being executed per person. Viewcount uses the same principes as soldcount. I hope this explains well, and you can help me with this.
Kind regards,
Stef
Hello @TrendBlend ,
understand your concerns, First think you don;t need to add localstorage because this sold items, max and min, Just add the javascript code simple so all screens show same even mobile and desktop, I pretty sure this count not come to the admin panel. use code,