最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Woocommerce redirection if no previous orders

programmeradmin3浏览0评论

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 1
Add a comment  | 

1 Answer 1

Reset to default 0

Since 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);
});
发布评论

评论列表(0)

  1. 暂无评论