Easy Digital Downloads – Fire code when payment is successful
Question
I just started with Easy Digital Downloads and i love it so far. I want to add data to the database when a payment was successful. For testing purpose i changed this to a echo. Unfortunately the echo isn’t fired. Can someone help me out?
I placed this function in the /includes/download-functions.php
//Fire codes when payment received
function wd_edd_run_when_purchase_complete( $payment_id, $new_status, $old_status ) {
// Make sure that payments are only completed once
if( $old_status == 'publish' || $old_status == 'complete' ) {
return;
}
// Make sure the payment completion is only processed when new status is complete
if( $new_status != 'publish' && $new_status != 'complete' ){
return;
}
$payment_data = edd_get_payment_meta( $payment_id );
$currentUser = $user_info['id'];
if ($download_id == "427") { // Item ID of downloaded file
echo "Item EDD item ID: 427 added to the database. Purchase by: ".$currentUser;
}
}
add_action( 'edd_update_payment_status', 'wd_edd_run_when_purchase_complete', 100, 3 );
0
plugins
4 years
2019-11-03T04:08:33-05:00
2019-11-03T04:08:33-05:00 0 Answers
78 views
0
Leave an answer