• Hi, after moving a Woocommerce store, the Client History data (on Order pages) is incorrect. Some show multiple purchases where there should be only one, some show NO purchases where there should be at least the current one.

    Is there any way to rebuild/recalculate this type of data?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @ravanh,

    Thanks for reaching out about this. That does sound unusual, especially if the customer purchase counts changed after the store migration.

    WooCommerce calculates the “Customer history” data based on the orders linked to a customer account or billing email, so if something changed during the migration, such as user IDs, order associations, or duplicated data, it could affect the counts being shown.

    To help narrow this down, could you let us know:

    1. Was the site migrated to a new domain, server, or both?
    2. Did you use a migration plugin or restore from a backup?
    3. Have you already tried a conflict test by temporarily disabling all plugins except WooCommerce and switching to a default theme like Twenty Twenty-Four to see if the counts change?
    4. Are the affected orders linked to registered customer accounts, guest orders, or both?

    Also, please share your WooCommerce System Status Report so we can take a closer look: https://woocommerce.com/document/understanding-the-woocommerce-system-status-report/

    You can paste it via https://pastebin.com or https://quickforget.com and share the link here.

    Thread Starter Rolf Allard van Hagen

    (@ravanh)

    Hi,

    1. Was the site migrated to a new domain, server, or both?

    New server.

    1. Did you use a migration plugin or restore from a backup?

    Restore from a backup, but also a manual import of latest orders that occurred during the migration. I suspect it went wrong there…

    1. Have you already tried a conflict test by temporarily disabling all plugins except WooCommerce and switching to a default theme like Twenty Twenty-Four to see if the counts change?

    I tried the Health Check & Troubleshooting plugin, with only Woocommerce reactivated. The History calculations are still wrong then. The weird thing: only 922 of the current 1430 orders appear on the Orders admin page. Is this a hint of what could be wrong?

    1. Are the affected orders linked to registered customer accounts, guest orders, or both?

    Both. I notice guest orders often show 0 orders in their history while registered show too many. But even for those that have the correct order number, the average and total amounts are wrong.

    My report on pastebin https://pastebin.com/7dv6btGy

    Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @ravanh,

    Thanks for sharing those additional details and the System Status Report. The fact that only 922 out of 1430 orders are appearing in the Orders admin page is definitely a strong clue here, especially combined with the incorrect customer history calculations.

    From what you described, it does sound possible that the manual order import during the migration may have caused inconsistencies between the WooCommerce order tables and the lookup tables WooCommerce uses for customer statistics and order history.

    I also noticed from your report that HPOS is enabled on the site. Since HPOS stores orders in dedicated WooCommerce tables, partial imports or mismatched sync data can sometimes lead to symptoms like:

    • Incorrect customer order counts
    • Wrong average or total spent values
    • Guest orders not being linked correctly
    • Missing orders in the admin Orders list

    To start narrowing this down further, could you please check the following:

    1. Go to WooCommerce → Status → Tools
    2. Run these tools one at a time:
      • Regenerate the product lookup tables
      • Recount terms
      • Clear analytics cache
    3. Then check under: WooCommerce → Settings → Advanced → Features

    Please temporarily disable HPOS compatibility mode if enabled, save changes, then re-enable it and allow WooCommerce to resync the order data.

    1. Also, can you confirm:
      • Were the manually imported orders imported directly into the database, or through a plugin/tool?
      • Do the “missing” orders still exist in the wp_wc_orders table and wp_posts table, or only one of them?

    Since the issue persists even in Health Check troubleshooting mode, this is looking less like a plugin conflict and more like a data synchronization or migration inconsistency.

    Let us know what you find after the above checks and we’ll continue from there.

    Thread Starter Rolf Allard van Hagen

    (@ravanh)

    Ok, I ran the Tools and disabled HPOS Data Caching option (is that what you meant with HPOS compatibility mode?) but the order history calculations are still off.

    I do remember that we switched from Legacy to High-performance order storage after the move. Could that have caused this?

    HPOS Data Caching was switched on because there is a Redis Object Cache on the new hosting environment.

    We did a manual db import of the woocommerce order and customer tables but also a export/import via the WordPress export tool because we noticed a weird issue where some of the latest orders could not be selected (no check box) on the Orders overview admin page.

    About the “missing” orders on the Orders overview admin page: this only happens when in Health Check troubleshooting mode. Then there appear only (today) 923 orders instead of 1,431 without troubleshooting mode.

    I compared the wp_wc_orders table and wp_posts tables:

    • wp_posts has 1524 entries with post type shop_order
    • wc_orders has 1431 entries with type shop_order

    The orders that go missing in Health Check troubleshooting mode, are present in both the wp_wc_orders table and wp_posts tables. In fact, there appear to be 93 more in the wp_posts table. This may well correspond with the number of orders that occurred between the first and the final export/import before switching to the new hosting platform… No idea though, how they would be “doubled” during the process.

    Plugin Support Frank Remmy (woo-hc)

    (@frankremmy)

    Hi @ravanh,

    Thanks for the detailed investigation. Those database comparisons are really useful!

    The 93 extra orders in wp_posts compared to wc_orders is the core of the problem. Those are orders that exist in the legacy post-based storage but never made it into the HPOS wc_orders table; almost certainly the orders that were imported during the migration window before you switched to HPOS. Because HPOS reads from wc_orders, those 93 orders are effectively invisible to it, but they’re still being counted in some of the customer lookup data, which is why order counts and totals are coming out wrong.

    The switch from Legacy to HPOS after the migration also means the sync between the two tables was never completed properly for those orders.

    Here’s what to try:

    • Go to WooCommerce → Settings → Advanced → Features, enable “Enable compatibility mode,” and click “Resync order now”: https://share.zight.com/jkuGwqEG. This will trigger WooCommerce to sync the legacy wp_posts orders into wc_orders, which should bring those 93 missing orders across. Leave it running until the sync completes.
    • Once the sync is complete, go to WooCommerce → Status → Tools and run “Update database” followed by “Regenerate the product lookup tables”. This will rebuild the wc_customer_lookup and wc_order_stats tables from the corrected order data, which should fix the wrong counts and totals in customer histories.
    • Before doing anything with those duplicate orders in wp_posts, please take a full database backup first. Once the sync is complete, check whether those 93 entries have been properly brought into wc_orders. If they remain as orphaned duplicates after the sync, we can advise on how to safely clean them up.

    On the missing orders in troubleshooting mode (923 vs 1,431): that difference is likely because some orders belong to custom statuses registered by plugins that are inactive in troubleshooting mode; those orders aren’t gone, they just can’t be displayed without the plugin that registered their status. This is a separate issue from the history calculations.

    Let us know how the sync goes!

    Hi @frankremmy I did the switch to compatibility mode with resync and ran the tools… but the order counts remain the same. Some are good, some are too many, and a few are zero.

    And the 93 difference between the wp_posts and wc_orders entries remains…

    I should note: the counts are off even for some orders that occurred after the move, in the last few days.

    Plugin Support Frank Remmy (woo-hc)

    (@frankremmy)

    Hi @ravanh,

    Thank you for the update, and the fact that orders placed after the migration are also showing incorrect counts is really important. It means this isn’t just a legacy data issue but something actively affecting new orders too.

    Given that Redis object caching is running on your new host, our strong suspicion is that the Redis cache is serving stale customer lookup data even after you rebuilt the tables. The rebuild writes correct data to the database, but if Redis is still holding old values, WooCommerce reads from cache and nothing appears to change.

    Please try the following:

    • Contact your hosting provider and ask them to flush the Redis object cache entirely, or do it yourself via WP-CLI:
    wp cache flush
    • Go to WooCommerce → Status → Tools and run “Regenerate the product lookup tables” again, then check whether customer history counts improve for recent orders.
    • Pick one order placed in the last few days that shows wrong counts. Note the customer’s billing email, then run this query in phpMyAdmin to check what wc_customer_lookup has for them:
    SELECT * FROM wp_wc_customer_lookup WHERE email = '[email protected]';

    This will tell us whether the lookup table itself has wrong data or whether it’s a cache/display issue.

    On the 93 orphan orders in wp_posts: The HPOS sync silently skipped those, likely because they have incomplete or malformed data from the double-import. Those will need to be investigated separately, but let’s fix the active calculation issue first.

    Looking forward to your findings!

    To make sure, I deactivated the redis object cache completely and then regenerated, but still, the history data remains off.

    I then took the email from the latest order with wrong history data (2 orders instead of 1) and checked that against the wc_customer_lookup table an it turns out to hold only one entry. Did a search for the email from an older order that shows 0 orders in the History data and that also showed one entry.

    But I suppose this is to be expected, because search for an email from a customer that has multiple orders that correctly show in his History, also returned only one result in the wc_customer_lookup table.

    All customer data there seems to be correct. What does that tell us?

    I finally found two older orders with 0 in the customer history, where the email did not return any results from the wc_customer_lookup table. These are both from customers that ordered as Guest, while most others (with 0 in history but present in the lookup table) have a user account… Not sure if this last info is relevant or useful…

Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.