• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / EDD_Customer::remove_payment() – Remove a payment from this customer, then triggers reducing stats

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;

  }
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 12th September 2021

Primary Sidebar

Information

Function name: EDD_Customer::remove_payment
Class ref: EDD_Customer
Plugin ref: Easy Digital Downloads
Version: 2.11.6
Sourcefile: includes/class-edd-customer.php
File ref: includes/class-edd-customer.php
Deprecated?: No
API Letters: C,E,P,R

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.9.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites