Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurtschlatzer/6f58cb9c7099c93ffad6893d73af1fed to your computer and use it in GitHub Desktop.
Save kurtschlatzer/6f58cb9c7099c93ffad6893d73af1fed 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment