diff --git a/includes/admin/payments/actions.php b/includes/admin/payments/actions.php index 454c6bb9429..39104e93c71 100644 --- a/includes/admin/payments/actions.php +++ b/includes/admin/payments/actions.php @@ -214,10 +214,10 @@ function edd_update_payment_details( $data ) { $customer->attach_payment( $payment_id, false ); // If purchase was completed and not ever refunded, adjust stats of customers - if( 'revoked' == $status || 'publish' == $status ) { + if( 'publish' == $status ) { $previous_customer->decrease_purchase_count(); - $previous_customer->decrease_value( $new_total ); + $previous_customer->decrease_value( $curr_total ); $customer->increase_purchase_count(); $customer->increase_value( $new_total ); @@ -250,18 +250,23 @@ function edd_update_payment_details( $data ) { $payment->status = $status; // Adjust total store earnings if the payment total has been changed - if ( $new_total !== $curr_total && ( 'publish' == $status || 'revoked' == $status ) ) { + if ( $new_total !== $curr_total && ( 'publish' == $status ) ) { if ( $new_total > $curr_total ) { // Increase if our new total is higher $difference = $new_total - $curr_total; edd_increase_total_earnings( $difference ); + if ( !$customer_changed ) { + $customer->increase_value( $difference ); + } } elseif ( $curr_total > $new_total ) { // Decrease if our new total is lower $difference = $curr_total - $new_total; edd_decrease_total_earnings( $difference ); - + if ( !$customer_changed ) { + $customer->decrease_value( $difference ); + } } } diff --git a/includes/class-edd-customer.php b/includes/class-edd-customer.php index 889c6ee6d8d..2bdc627a384 100644 --- a/includes/class-edd-customer.php +++ b/includes/class-edd-customer.php @@ -347,7 +347,7 @@ public function remove_payment( $payment_id = 0, $update_stats = true ) { $payment = new EDD_Payment( $payment_id ); - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { + if ( 'publish' !== $payment->status ) { $update_stats = false; } diff --git a/includes/payments/functions.php b/includes/payments/functions.php index 0b1f10b9483..46b3c074217 100644 --- a/includes/payments/functions.php +++ b/includes/payments/functions.php @@ -279,14 +279,6 @@ function edd_delete_purchase( $payment_id = 0, $update_customer = true, $delete_ edd_decrease_total_earnings( $amount ); // Clear the This Month earnings (this_monththis_month is NOT a typo) delete_transient( md5( 'edd_earnings_this_monththis_month' ) ); - - if( $customer->id && $update_customer ) { - - // Decrement the stats for the customer - $customer->decrease_purchase_count(); - $customer->decrease_value( $amount ); - - } } if( $customer->id && $update_customer ) {