WooCommerce order query timing out with memory errors
-
I have this order query using
wc_get_orders
that isn’t working anymore for some reason. Nobody changed the code, but this stopped working recently on a site that has a lot of order information. I have some suspicion about this being due to the amount of order data in the database, but I’ll let the community weigh in on this; because I’m really unsure.This is what we’ve been working with:
$orders = wc_get_orders(array( 'status' => array('wc-processing', 'wc-on-hold'), 'type' => 'shop_order', 'limit' => -1 ));
This produces a memory error. But if I do the following, I do get an array of ids back:
$orders = wc_get_orders(array( 'status' => array('wc-processing', 'wc-on-hold'), 'type' => 'shop_order', 'limit' => -1, 'return' => 'ids' ));
The thing is, if I remove the
return
argument from this, documentation says I should be getting back an object. But I don’t, I just get the error or an empty array. Limiting the number of posts isn’t helping, either.Is there a better or more-performant way of doing this? So far I’ve been striking out. Thanks!
- The topic ‘WooCommerce order query timing out with memory errors’ is closed to new replies.