Easy Digital Downloads
  • Package
  • Function
  • Tree

Packages

  • EDD
    • Admin
      • Actions
      • Add-ons
      • Dashboard
      • Discounts
      • Downloads
      • Export
      • Notices
      • Pages
      • Payments
      • Reports
      • Settings
      • System
      • Upgrades
      • Upload
      • Welcome
    • Cart
    • Checkout
    • Classes
      • API
      • Fees
      • HTML
      • Roles
      • Session
    • Emails
    • Functions
      • AJAX
      • Compatibility
      • Errors
      • Formatting
      • Install
      • Login
      • Taxes
      • Templates
    • Gateways
    • Logging
    • Payments
    • Shortcodes
    • Widgets

Functions

  • edd_admin_email_notice
  • edd_apply_email_template
  • edd_default_email_styling
  • edd_default_email_template
  • edd_email_default_formatting
  • edd_email_preview_templage_tags
  • edd_email_purchase_receipt
  • edd_email_template_preview
  • edd_email_template_tags
  • edd_email_test_purchase_receipt
  • edd_get_admin_notice_emails
  • edd_get_email_body_content
  • edd_get_email_body_footer
  • edd_get_email_body_header
  • edd_get_email_templates
  • edd_render_receipt_in_browser
  • edd_resend_purchase_receipt
  • edd_send_test_email
  • edd_trigger_purchase_receipt
 1 <?php
 2 /**
 3  * Email Actions
 4  *
 5  * @package     EDD
 6  * @subpackage  Emails
 7  * @copyright   Copyright (c) 2013, Pippin Williamson
 8  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 9  * @since       1.0.8.2
10  */
11 
12 // Exit if accessed directly
13 if ( ! defined( 'ABSPATH' ) ) exit;
14 
15 /**
16  * Triggers Purchase Receipt to be sent after the payment status is updated
17  *
18  * @since 1.0.8.4
19  * @param int $payment_id Payment ID
20  * @param string $new_status New Payment Status (e.g. Complete)
21  * @param string $old_status Old Payment Status (e.g. Pending)
22  * @return void
23  */
24 function edd_trigger_purchase_receipt( $payment_id, $new_status, $old_status ) {
25     // Make sure we don't send a purchase receipt while editing a payment
26     if ( isset( $_POST['edd-action'] ) && $_POST['edd-action'] == 'edit_payment' )
27         return;
28 
29     // Check if the payment was already set to complete
30     if ( $old_status == 'publish' || $old_status == 'complete' )
31         return; // Make sure that payments are only completed once
32 
33     // Make sure the receipt is only sent when new status is complete
34     if ( $new_status != 'publish' && $new_status != 'complete' )
35         return;
36 
37     // Send email with secure download link
38     edd_email_purchase_receipt( $payment_id );
39 }
40 add_action( 'edd_update_payment_status', 'edd_trigger_purchase_receipt', 10, 3 );
41 
42 /**
43  * Resend the Email Purchase Receipt. (This can be done from the Payment History page)
44  *
45  * @since 1.0
46  * @param array $data Payment Data
47  * @return void
48  */
49 function edd_resend_purchase_receipt( $data ) {
50     $purchase_id = $data['purchase_id'];
51     edd_email_purchase_receipt( $purchase_id, false );
52 
53     // Grab all downloads of the purchase and update their file download limits, if needed
54     // This allows admins to resend purchase receipts to grant additional file downloads
55     $downloads = edd_get_payment_meta_downloads( $purchase_id );
56 
57     if ( is_array( $downloads ) ) {
58         foreach ( $downloads as $download ) {
59             $limit = edd_get_file_download_limit( $download['id'] );
60             if ( ! empty( $limit ) ) {
61                 edd_set_file_download_limit_override( $download['id'], $purchase_id );
62             }
63         }
64     }
65 
66     wp_redirect( add_query_arg( array( 'edd-message' => 'email_sent', 'edd-action' => false, 'purchase_id' => false ) ) );
67     exit;
68 }
69 add_action( 'edd_email_links', 'edd_resend_purchase_receipt' );
70 
71 /**
72  * Trigger the sending of a Test Email
73  *
74  * @since 1.5
75  * @param array $data Paramaters sent from Settings page
76  * @return void
77  */
78 function edd_send_test_email( $data ) {
79     if ( ! wp_verify_nonce( $data['_wpnonce'], 'edd-test-email' ) )
80         return;
81 
82     // Send a test email
83     edd_email_test_purchase_receipt();
84 }
85 add_action( 'edd_send_test_email', 'edd_send_test_email' );
Easy Digital Downloads API documentation generated by ApiGen 2.8.0