You appear to be a bot. Output may be restricted
Description
Set up and store a payment record from a CSV row
Usage
$void = EDD_Batch_Payments_Import::create_payment( $row );
Parameters
- $row
- ( mixed ) optional –
Returns
void
Source
File name: easy-digital-downloads/includes/admin/import/class-batch-import-payments.php
Lines:
1 to 100 of 268
public function create_payment( $row = array() ) { $payment = new EDD_Payment; $payment->status = 'pending'; if( ! empty( $this->field_mapping['number'] ) && ! empty( $row[ $this->field_mapping['number'] ] ) ) { $payment->number = sanitize_text_field( $row[ $this->field_mapping['number'] ] ); } if( ! empty( $this->field_mapping['mode'] ) && ! empty( $row[ $this->field_mapping['mode'] ] ) ) { $mode = strtolower( sanitize_text_field( $row[ $this->field_mapping['mode'] ] ) ); $mode = 'test' != $mode && 'live' != $mode ? false : $mode; if( ! $mode ) { $mode = edd_is_test_mode() ? 'test' : 'live'; } $payment->mode = $mode; } if( ! empty( $this->field_mapping['date'] ) && ! empty( $row[ $this->field_mapping['date'] ] ) ) { $date = sanitize_text_field( $row[ $this->field_mapping['date'] ] ); if( ! strtotime( $date ) ) { $date = date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ); } else { $date = date( 'Y-m-d H:i:s', strtotime( $date ) ); } $payment->date = $date; } $payment->customer_id = $this->set_customer( $row ); if( ! empty( $this->field_mapping['email'] ) && ! empty( $row[ $this->field_mapping['email'] ] ) ) { $payment->email = sanitize_text_field( $row[ $this->field_mapping['email'] ] ); } if ( ! empty( $this->field_mapping['name'] ) && ! empty( $row[ $this->field_mapping['name'] ] ) ) { $payment->name = sanitize_text_field( $row[ $this->field_mapping['name'] ] ); } else { if ( ! empty( $this->field_mapping['first_name'] ) && ! empty( $row[ $this->field_mapping['first_name'] ] ) ) { $payment->first_name = sanitize_text_field( $row[ $this->field_mapping['first_name'] ] ); } if ( ! empty( $this->field_mapping['last_name'] ) && ! empty( $row[ $this->field_mapping['last_name'] ] ) ) { $payment->last_name = sanitize_text_field( $row[ $this->field_mapping['last_name'] ] ); } } if( ! empty( $this->field_mapping['user_id'] ) && ! empty( $row[ $this->field_mapping['user_id'] ] ) ) { $user_id = sanitize_text_field( $row[ $this->field_mapping['user_id'] ] ); if( is_numeric( $user_id ) ) { $user_id = absint( $row[ $this->field_mapping['user_id'] ] ); $user = get_userdata( $user_id ); } elseif( is_email( $user_id ) ) { $user = get_user_by( 'email', $user_id ); } else { $user = get_user_by( 'login', $user_id ); } if( $user ) { $payment->user_id = $user->ID; $customer = new EDD_Customer( $payment->customer_id ); if( empty( $customer->user_id ) ) { $customer->update( array( 'user_id' => $user->ID ) ); } } }