TANMOY1

How Many Item Sold Last 24h

Oct 9th, 2025
2,950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. <!-- HTML for Product Page 2 -->
  2. <div id="sold-message-2" style="display: flex; align-items: center; gap: 5px; background-color:#fdf7f4; padding: 6px; border-radius: 14px; font-size: 11px; font-weight: bold; color: #333; position: relative;">
  3. <span>✅</span> <!-- New emoji -->
  4. <span id="sold-number-2">none</span> sold in last 24 hours
  5. <div id="stock-message" style="margin-left: auto;">
  6. <span class="limited-stock">* Few Left</span> <!-- Updated text -->
  7. </div>
  8. </div>
  9.  
  10. <!-- CSS (Same for all product pages) -->
  11. <style>
  12. #sold-message-2 {
  13. background-color: #f9f4e4; /* Light but slightly darker color */
  14. }
  15.  
  16. .limited-stock {
  17. color: red; /* Text color red */
  18. font-weight: bold; /* Bold text */
  19. animation: blinkText 2s infinite; /* Slower blinking animation */
  20. }
  21.  
  22. @keyframes blinkText {
  23. 0% { opacity: 1; }
  24. 50% { opacity: 0; }
  25. 100% { opacity: 1; }
  26. }
  27. </style>
  28.  
  29. <!-- JavaScript for Product Page 2 -->
  30. <script>
  31. function updateSoldNumber2() {
  32. // Generate a random number between 18 and 29
  33. const soldNumber = Math.floor(Math.random() * (29 - 18 + 1)) + 18;
  34. document.getElementById('sold-number-2').textContent = soldNumber;
  35. localStorage.setItem('lastSoldNumber_2', soldNumber); // Store the number with a unique key for this product
  36. localStorage.setItem('lastUpdate_2', Date.now()); // Store the update time with a unique key for this product
  37. }
  38.  
  39. function initializeSoldNumber2() {
  40. const lastSoldNumber = localStorage.getItem('lastSoldNumber_2');
  41. const lastUpdate = localStorage.getItem('lastUpdate_2');
  42. const now = Date.now();
  43. const interval = 77000; // 1 minute and 17 seconds in milliseconds
  44.  
  45. if (lastSoldNumber) {
  46. // If there is a stored number, use it
  47. document.getElementById('sold-number-2').textContent = lastSoldNumber;
  48. }
  49.  
  50. if (!lastUpdate) {
  51. // If no update time is stored, perform an initial update
  52. updateSoldNumber2();
  53. } else {
  54. const elapsed = now - lastUpdate;
  55.  
  56. if (elapsed >= interval) {
  57. // If it's been 77 seconds or more since the last update, update the number
  58. updateSoldNumber2();
  59. } else {
  60. // Schedule the next update based on the remaining time
  61. const timeLeft = interval - elapsed;
  62. setTimeout(updateSoldNumber2, timeLeft);
  63. }
  64. }
  65. }
  66.  
  67. // Initialize on page load
  68. initializeSoldNumber2();
  69. // Update number every 1 minute and 17 seconds
  70. setInterval(updateSoldNumber2, 77000);
  71. </script>
Advertisement
Add Comment
Please, Sign In to add comment