Skip to content

Instantly share code, notes, and snippets.

@nhadsall
nhadsall / fix_get_total_spent.php
Last active March 29, 2023 11:28
Fix WooCommerce get_total_spent()
<?php
class SPROUT_order_total {
private $orders = [];
function __construct() {
add_action( "woocommerce_before_order_object_save", [ $this, 'save_order' ], 1000, 2 );
add_filter( "woocommerce_customer_get_total_spent_query", [ $this, 'intercept_query' ], 1000, 2 );
}
function intercept_query( $query, $customer ) {