Created
December 16, 2013 18:45
-
-
Save sidharrell/7992131 to your computer and use it in GitHub Desktop.
custom espresso_update_attendee_payment_status_in_db to work with partial payments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function espresso_update_attendee_payment_status_in_db_custom($payment_data) { | |
| // echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>'; | |
| remove_filter('filter_hook_espresso_update_attendee_payment_data_in_db', 'espresso_update_attendee_payment_status_in_db'); | |
| global $wpdb; | |
| $payment_data['payment_date'] = date(get_option('date_format')); | |
| if ($payment_data['payment_status'] == "Completed") { | |
| $payment = $payment_data['total_cost']; | |
| } elseif($payment_data['payment_status'] == "Pending" && !empty($payment_data['amount_paid'])) { | |
| $payment_data['amount_pd'] = $payment_data['amount_pd'] + $payment_data['amount_paid']; | |
| $payment = $payment_data['amount_pd']; | |
| } else { | |
| return $payment_data; | |
| } | |
| $wpdb->update( | |
| EVENTS_ATTENDEE_TABLE, | |
| array( 'amount_pd' => $payment ), | |
| array( 'id' => $payment_data['attendee_id'] ), | |
| array( '%f' ), | |
| array( '%d' ) | |
| ); | |
| $payment_data['txn_details'] = empty( $payment_data['txn_details'] ) ? serialize( $_REQUEST ) : $payment_data['txn_details']; | |
| $wpdb->update( | |
| EVENTS_ATTENDEE_TABLE, | |
| array( | |
| 'payment_status' => $payment_data['payment_status'], | |
| 'txn_type' => $payment_data['txn_type'], | |
| 'txn_id' => $payment_data['txn_id'], | |
| 'payment_date' => $payment_data['payment_date'], | |
| 'transaction_details' => $payment_data['txn_details'], | |
| 'date'=>current_time('mysql') | |
| ), | |
| array( 'attendee_session' => $payment_data['attendee_session'] ), | |
| array( '%s', '%s', '%s', '%s', '%s','%s' ), | |
| array( '%s' ) | |
| ); | |
| do_action('action_hook_espresso_track_successful_sale',$payment_data); | |
| return $payment_data; | |
| } | |
| add_filter('filter_hook_espresso_update_attendee_payment_data_in_db', 'espresso_update_attendee_payment_status_in_db_custom', 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment