Skip to content

Commit

Permalink
PB-732 Naprawić zliczanie kodów zniżkowych
Browse files Browse the repository at this point in the history
  • Loading branch information
mbwawpl committed Aug 14, 2023
1 parent d1de399 commit 8040917
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions includes/payments/class-edd-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,6 @@ public function update_status( $status = false ) {
$this->process_refund();
break;
case 'failed':
$this->process_failure();
break;
case 'pending':
$this->process_pending();
Expand Down Expand Up @@ -1586,36 +1585,26 @@ private function process_refund() {
$decrease_customer_value = apply_filters( 'edd_decrease_customer_value_on_refund', true, $this );
$decrease_purchase_count = apply_filters( 'edd_decrease_customer_purchase_count_on_refund', true, $this );

$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
$this->delete_sales_logs();

// Clear the This Month earnings (this_monththis_month is NOT a typo)
delete_transient( md5( 'edd_earnings_this_monththis_month' ) );

do_action( 'edd_post_refund_payment', $this );
}

/**
* Process when a payment is set to failed, decrement discount usages and other stats
*
* @since 2.5.7
* @return void
*/
private function process_failure() {

$discounts = $this->discounts;
if ( 'none' === $discounts || empty( $discounts ) ) {
return;
return;
}

if ( ! is_array( $discounts ) ) {
$discounts = array_map( 'trim', explode( ',', $discounts ) );
$discounts = array_map( 'trim', explode( ',', $discounts ) );
}

foreach ( $discounts as $discount ) {
edd_decrease_discount_usage( $discount );
edd_decrease_discount_usage( $discount );
}

$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
$this->delete_sales_logs();

// Clear the This Month earnings (this_monththis_month is NOT a typo)
delete_transient( md5( 'edd_earnings_this_monththis_month' ) );

do_action( 'edd_post_refund_payment', $this );
}

/**
Expand Down

0 comments on commit 8040917

Please sign in to comment.