Last active
April 14, 2022 20:59
-
-
Save bryceadams/050d886159265d6f5e6dbce649552704 to your computer and use it in GitHub Desktop.
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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.