1) Yes, absolutely. Are you familiar with WordPress action hooks?
2). This won’t be possible as the email / user info is required for processing file downloads.
Thread Starter
Kjow
(@kjow)
1) Unfortunately, not. But I could try! I will look for tutorial about these.
What do I need to do with action hooks?
2) Ok, so I need a download manager for free files and “Easy Digital Downloads” for purchases. 🙂
Thank you!
Kjow
1) I can show you a simple example. Do you want to run a function when a purchase is first made, or when its payment is confirmed as complete?
2) If you want to avoid the checkout process, yes.
Thread Starter
Kjow
(@kjow)
1) Yes, thank you!
At the moment I need when the payment is confirmed as complete.
🙂
Here you go:
function pw_runs_when_payment_complete($payment_id, $new_status, $old_status) {
if( $old_status == 'publish' || $old_status == 'complete')
return; // make sure that payments are only completed once
if( ! edd_is_test_mode() ) {
$payment_data = get_post_meta($payment_id, '_edd_payment_meta', true);
$downloads = maybe_unserialize($payment_data['downloads']);
$user_info = maybe_unserialize($payment_data['user_info']);
$cart_details = maybe_unserialize($payment_data['cart_details']);
// run something for each product purchased
foreach($downloads as $download) {
// $download['id'] is the ID number of the product purchased
// $payment_data, $user_info, and $cart details contain a lot of other info you might need.
}
}
// empty the shopping cart
edd_empty_cart();
}
add_action('edd_update_payment_status', 'pw_runs_when_payment_complete', 10, 3);