You appear to be a bot. Output may be restricted
Description
Remove a payment from this customer, then triggers reducing stats
Usage
$boolean = EDD_Customer::remove_payment( $payment_id, $update_stats );
Parameters
- $payment_id
- ( integer ) optional – The Payment ID to remove
- $update_stats
- ( bool ) optional default: 1 – For backwards compatibility, if we should increase the stats or not
Returns
boolean If the removal was successful
Source
File name: easy-digital-downloads/includes/class-edd-customer.php
Lines:
1 to 54 of 54
public function remove_payment( $payment_id = 0, $update_stats = true ) { if( empty( $payment_id ) ) { return false; } $payment = new EDD_Payment( $payment_id ); if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { $update_stats = false; } $new_payment_ids = ''; if( ! empty( $this->payment_ids ) ) { $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); $pos = array_search( $payment->ID, $payment_ids ); if ( false === $pos ) { return false; } unset( $payment_ids[ $pos ] ); $payment_ids = array_filter( $payment_ids ); $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); } do_action( 'edd_customer_pre_remove_payment', $payment->ID, $this->id ); $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); if ( $payment_removed ) { $this->payment_ids = $new_payment_ids; if ( $update_stats ) { // We removed this payment successfully, decrement the stats if ( ! empty( $payment->total ) ) { $this->decrease_value( $payment->total ); } $this->decrease_purchase_count(); } } do_action( 'edd_customer_post_remove_payment', $payment_removed, $payment->ID, $this->id, $this ); return $payment_removed; }