I am displaying logged in users their order history in the front end. Initially, when no order history, I used to get a blank page. However, after using this code
if ( !$customer_orders ) :
echo esc_html("You haven't redeemed any offer");
endif;
I can display a message in the front-end saying "You haven't redeemed any offer" I want this page to redirect after 5 seconds on if this message is being displayed, otherwise users will get to see their order details.
Can someone suggest something or extend this code? Check out the images for referenceWhere redirection has to happen after 5 seconds
I am displaying logged in users their order history in the front end. Initially, when no order history, I used to get a blank page. However, after using this code
if ( !$customer_orders ) :
echo esc_html("You haven't redeemed any offer");
endif;
I can display a message in the front-end saying "You haven't redeemed any offer" I want this page to redirect after 5 seconds on if this message is being displayed, otherwise users will get to see their order details.
Can someone suggest something or extend this code? Check out the images for referenceWhere redirection has to happen after 5 seconds
Share Improve this question asked Aug 2, 2020 at 18:09 Mohiz AhmadMohiz Ahmad 11 Answer
Reset to default 0Since you are looking for a redirect after 5 seconds so for this you need to use javascript timeout. You can enqueue script as per standards. Adding this script inside the condition of no orders will do the task.
jQuery(document).ready(function ($) {
window.setTimeout(function () {
location.href = "REDIRECT URL HERE";
}, 5000);
});