I’m using Easy Digital Downloads for my Wordpress webshop. After someone buys a item it needs to add credits to the MySQL database. I got this working by adding PHP code to shortcode-receipt.php.
This is working correct but when I reload the receipt via browser or mail the PHP code will fire again:
php
<?php
if( edd_is_payment_complete( $payment->ID ) && edd_receipt_show_download_files( $item['id'], $edd_receipt_args, $item ) ) :
?>
- Could someone help me out here?
- What is the best method to fire PHP code when a payment is successful?
Thanks in advance!
There is action
edd_complete_purchasewhich fires when order is completed.So, in your case, I would remove the code from the shortcode and created an plugin. Inside the plugin should be something like this