Last active
April 14, 2022 20:59
Star
You must be signed in to star a gist
Disable WooCommerce total spent / order count meta calculations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'get_user_metadata', 'mtkdocs_filter_user_metadata', 10, 4 ); | |
function mtkdocs_filter_user_metadata( $value, $object_id, $meta_key, $single ) { | |
// Check if it's one of the keys we want to filter | |
if ( in_array( $meta_key, array( '_money_spent', '_order_count' ) ) ) { | |
// Return 0 so WC doesn't try calculate it | |
return 0; | |
} | |
// Default | |
return $value; | |
} |
@JVDL-1 great to hear! :) No idea how the WC Analytics dashboard works / calculates numbers so I'd recommend testing thoroughly on your end to be sure. If needed, you could probably adjust the code to only run when your shipping partner gets the data.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bryceadams Thank you so much for this snippet. So much speed improvement for retrieving orders by our shipping partner. It would calculate total spend and order count for each order. Went from 100 orders in 5 minutes to about 30 sec!
Got a question, does the WooCommerce Analytics dashboard still works for total order count and total spent?
https://docs.woocommerce.com/document/woocommerce-analytics/#customers-report
Random picked some customers to check if the numbers still matched, which they seem to do. So that would indicate that WooCommerce Analytics dashboard does its own calculations. Is this right? Or did the snippet only disable the function partially?