order instanceof \EDD\Orders\Order && 'refund' === $payment->order->type ) { return; } // Send email with secure download link edd_email_purchase_receipt( $payment_id, true, '', $payment, $customer ); } add_action( 'edd_complete_purchase', 'edd_trigger_purchase_receipt', 999, 3 ); /** * Resend the Email Purchase Receipt. (This can be done from the Payment History page) * * @since 1.0 * @param array $data Payment Data * @return void */ function edd_resend_purchase_receipt( $data ) { $purchase_id = absint( $data['purchase_id'] ); if( empty( $purchase_id ) ) { return; } if( ! current_user_can( 'edit_shop_payments' ) ) { wp_die( __( 'You do not have permission to edit this payment record', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); } $email = ! empty( $_GET['email'] ) ? sanitize_email( $_GET['email'] ) : ''; if( empty( $email ) ) { $customer = new EDD_Customer( edd_get_payment_customer_id( $purchase_id ) ); $email = $customer->email; } $sent = edd_email_purchase_receipt( $purchase_id, false, $email ); // Grab all downloads of the purchase and update their file download limits, if needed // This allows admins to resend purchase receipts to grant additional file downloads $downloads = edd_get_payment_meta_cart_details( $purchase_id, true ); if ( is_array( $downloads ) ) { foreach ( $downloads as $download ) { $limit = edd_get_file_download_limit( $download['id'] ); if ( ! empty( $limit ) ) { edd_set_file_download_limit_override( $download['id'], $purchase_id ); } } } edd_redirect( add_query_arg( array( 'edd-message' => $sent ? 'email_sent' : 'email_send_failed', 'edd-action' => false, 'purchase_id' => false, ) ) ); } add_action( 'edd_email_links', 'edd_resend_purchase_receipt' ); /** * Trigger the sending of a Test Email * * @since 1.5 * @param array $data Parameters sent from Settings page * @return void */ function edd_send_test_email( $data ) { if ( ! wp_verify_nonce( $data['_wpnonce'], 'edd-test-email' ) ) { return; } // Send a test email edd_email_test_purchase_receipt(); $url = edd_get_admin_url( array( 'page' => 'edd-settings', 'tab' => 'emails', 'section' => 'purchase_receipts', 'edd-message' => 'test-purchase-email-sent', ) ); edd_redirect( $url ); } add_action( 'edd_send_test_email', 'edd_send_test_email' );