Automating the Store notice
-
I want to automate the store notice and I think I have the code ready to do so. I just can’t figure out where I would implement it so that it would affect the store notice.
This is the code that I made for the store notice
Scheduled HTML Execution<script> var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var currentdate = new Date(); var day = currentdate.getDay(); var hour = currentdate.getHours(); // Check if it's Friday and the time is 9 AM if (day === 5 && hour === 9) { // Run HTML code at the designated time var scheduledHtml = '<p class="woocommerce-store-notice demo_store" data-notice-id="63021a62384d5cd6d6cf42454d641e5a" style="display:block;" title="Shift-click to edit this element."><span class="customize-partial-edit-shortcut customize-partial-edit-shortcut-woocommerce_demo_store_notice"><button aria-label="Click to edit this element." title="Click to edit this element." class="customize-partial-edit-shortcut-button"><svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M13.89 3.39l2.71 2.72c.46.46.42 1.24.03 1.64l-8.01 8.02-5.56 1.16 1.16-5.58s7.6-7.63 7.99-8.03c.39-.39 1.22-.39 1.68.07zm-2.73 2.79l-5.59 5.61 1.11 1.11 5.54-5.65zm-2.97 8.23l5.58-5.6-1.07-1.08-5.59 5.6z"></path></svg></button></span>"The St. Isidore Market is currently closed for online ordering. Ordering begins Friday at 9 am for the next Market. Products are available for purchase without a preorder at the Market from 5-6:30 pm each Thursday. Please visit us! "<a href="#" class="woocommerce-store-notice__dismiss-link">::Dismiss "Dismiss"</a></p>'; document.getElementById('scheduledContent').innerHTML = scheduledHtml; } else if (day === 2 && hour === 12) { // Remove the notice on Tuesday at noon document.getElementById('scheduledContent').innerHTML = ""; } else { // Display the current date and time var ampm = hour >= 12 ? 'PM' : 'AM'; hour = hour % 12; hour = hour ? hour : 12; // Handle midnight var datetime = "Current Time: " + days[currentdate.getDay()] + " " + currentdate.getDate() + "/" + (currentdate.getMonth() + 1) + "/" + currentdate.getFullYear() + " @ " + hour + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds() + " " + ampm; document.getElementById('scheduledContent').innerHTML = "<p>" + datetime + "</p>"; } </script>
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Automating the Store notice’ is closed to new replies.