Problem: If no items are found in a View of WooCommerce Orders, I would like to automatically refresh the View results after a set amount of time.
Solution: There is no automatic feature for refreshing View results, nor is there a true JavaScript API for Views, but you could achieve something similar by reloading the current page in a setTimeout function added to a script tag in the wpv-no-items-found block of the View, for example:
[wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> <script type="text/javascript">setTimeout(function(){location.reload();}, 5000);</script> [/wpv-no-items-found]
This will reload the current page after 5 seconds if no results are found in the View. That loop of refreshing every 5 seconds would continue until results exist.
Relevant Documentation:
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 3 years, 5 months ago.
Assisted by: Christian Cox.