Skip to content

Instantly share code, notes, and snippets.

@bryceadams
Last active April 14, 2022 20:59
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bryceadams/050d886159265d6f5e6dbce649552704 to your computer and use it in GitHub Desktop.
Save bryceadams/050d886159265d6f5e6dbce649552704 to your computer and use it in GitHub Desktop.
Disable WooCommerce total spent / order count meta calculations
<?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;
}
@bryceadams
Copy link
Author

@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