Support » Plugin: WooCommerce » woocommerce displays incorrect orders in my-orders page

  • When I open my orders page, wooommerce shows random orders thats are not current user orders.
    I’ve disabled all plugins except woocommerce and Then I’ve acitivatd 2019 wordpress theme.
    Then I created this:

    function woocommerce_orders() {
    $test_user_id = 7;
    $user_id = $test_user_id;
    echo $user_id;
    if ($user_id == 0) {
    return do_shortcode(‘[woocommerce_my_account]’);
    }else{
    ob_start();
    wc_get_template( ‘myaccount/my-orders.php’, array(
    ‘current_user’ => $user_id,
    ‘order_count’ => $order_count
    ) );
    return ob_get_clean();
    }

    }
    add_shortcode(‘woocommerce_orders’, ‘woocommerce_orders’);

    And then I create a page with this shortcode in it:

    [woocommerce_orders]

    then I changed $test_user_id value to test it.
    It shows random orders when I change the id.
    Please tell me how can I solve this problem to show current user orders in my orders page.
    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    Hi @mr-seven,

    Are you looking to create a shortcode to display the current user’s orders or is this happening in the order section of the accounts page?

    Let me know and we’ll go from there.

    Take care,

    Thread Starter Sadegh Hosseini

    (@mr-seven)

    Hi @3sonsdevelopment ,

    No, I don’t want to create a shortcode to display user’s orders.
    this happening in the order section of the accounts page.
    I just used that shortcode to test the problem.

    Thanks for your answer,

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    Hi @mr-seven,

    One way that can happen is when the account page is cached. It ends up serving content from other users instead of the current one. If you have a caching plugin or the server has caching built-in, make sure it excludes the cart, checkout and account pages.

    Does any other information shown in the account section match other customers instead of the current one?

    Best,

    Thread Starter Sadegh Hosseini

    (@mr-seven)

    Hi @3sonsdevelopment ,
    I’ve disabled all of my plugins (cache plugin included) and the problem doesn’t solved.

    Does any other information shown in the account section match other customers instead of the current one?

    No, just orders.

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    Hello @mr-seven,

    That is really unusual. At this point, I would set up a staging and use the Twenty Nineteen theme and only WooCommerce. Then see if the orders are displayed correctly in the account page.

    Let me know what you turn up there.

    Cheers,

    Thread Starter Sadegh Hosseini

    (@mr-seven)

    Hello @3sonsdevelopment and Thanks for your support

    As I said in my first post:

    I’ve disabled all plugins except woocommerce and Then I’ve acitivatd 2019 wordpress theme.

    Thanks

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    Hi @mr-seven,

    My apologies for missing that from the first post. Good work trying that at the start.

    If you go to WooCommerce > Orders in the admin and filter by a customer do the correct orders show there?

    When a user is logged in and see orders from other customers in their account, are they able to view the other customer’s orders if they click on one?

    Let me know and we’ll go from there.

    Thanks,

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    Hi @mr-seven,

    It’s been a while since we heard from you, so I’m marking this thread resolved. Hopefully, you’ve been able to resolve this, but if you haven’t, please let open up a new topic and we’ll be happy to help out.

    Cheers

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘woocommerce displays incorrect orders in my-orders page’ is closed to new replies.