Speed up WooCommerce’s “Get total spent” query

When a customer places their first order, WooCommerce calculates the total spent by running a very slow query. This Power Tweak replaces this query by two separate and much more efficient queries.

This will be specially effective on an e-commerce website with a large amount of customers and orders.

It uses the filter woocommerce_customer_get_total_spent to calculate the total spent when the user meta _money_spent is not set.

This issue has been reported to WooCommerce, but not addressed yet (See issue on Github).

 

Posted in: Power tweaks