• […] has a tutorial on automatically linking past orders to WooCommerce customers when they register on your […]

  • Doug Smith 9 months ago Reply

    I had always wondered why this was not done automatically. It makes perfect sense now after reading your explanation of how it works.

    I did a little digging and found that the Customer List report actually does a similar search for previous orders just to decide if the button to link previous orders should be shown or not. It only returns the first order it can find with a matching e-mail address, but it’s still pretty intensive. The report won’t even finish loading the page on a site I have with a lot of orders—and now I understand why.

    • Beka Rice 9 months ago Reply

      Yep, that makes sense! As you can see this query is already being abstracted to use the new wc_get_orders() method, so hopefully when the underlying structure changes it can be much faster.

  • Gabrielle 7 months ago Reply

    Hi, what is, in your opinion, best setup for WC shop owners,
    when they just starting fresh on-line store?
    To force only registered users to register before buying product,
    and in long termprevent this time-consuming wc queries on register.
    Or allow unregistered users to buy, and when a blog/shop gets large
    in any post types number remove this snippet?
    Will WC authors consider to add this functions as default?
    Sorry for my poor English.

    • Beka Rice 7 months ago Reply

      Hey Gabrielle, we recommend allowing guest checkout, as there’s a fair bit of research that indicates allowing guest checkout improves conversions. I’d likely recommend this approach: “Or allow unregistered users to buy, and when a blog/shop gets large in any post types number remove this snippet?” Hopefully, for a new store, by the time your store gets large enough that this snippet would cause issues, WooCommerce will have already moved orders to a new data type (not posts), so one could avoid the issues I’ve outlined here 🙂

  • Timothy Burgin 5 days ago Reply

    Has this happened yet: “when WooCommerce migrates to a custom data structure (probably in v3.0) this query could likely be optimized a lot by then”?
    If WooCommerce has migrated to a custom data structure does your code need to be updated and if so how?

    • Beka Rice 4 days ago Reply

      WooCommerce hasn’t done so yet — the current v3.0 was originally v2.7. So 3.0 added the helpers to make a custom data structure possible, but this isn’t coming until v4.0.

      • Timothy Burgin 4 days ago Reply

        Ok, thank you!

Submit a Comment