/**
 * Email Download Purchase Receipt
 *
 * Email the download link(s) and payment confirmation to the buyer.
 *
 * @access      private
 * @since       1.0
 * @return      void
*/
function edd_email_purchase_receipt($payment_id, $admin_notice = true)
{
    global $edd_options;
    $payment_data = edd_get_payment_meta($payment_id);
    $user_info = maybe_unserialize($payment_data['user_info']);
    if (isset($user_info['id']) && $user_info['id'] > 0) {
        $user_data = get_userdata($user_info['id']);
        $name = $user_data->display_name;
    } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
        $name = $user_info['first_name'] . ' ' . $user_info['last_name'];
    } else {
        $name = $user_info['email'];
    }
    $message = edd_get_email_body_header();
    $message .= edd_get_email_body_content($payment_id, $payment_data);
    $message .= edd_get_email_body_footer();
    $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
    $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
    $subject = isset($edd_options['purchase_subject']) && strlen(trim($edd_options['purchase_subject'])) > 0 ? edd_email_template_tags($edd_options['purchase_subject'], $payment_data, $payment_id) : __('Purchase Receipt', 'edd');
    $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
    $headers .= "Reply-To: " . $from_email . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=utf-8\r\n";
    // allow add-ons to add file attachments
    $attachments = apply_filters('edd_receipt_attachments', array(), $payment_id, $payment_data);
    wp_mail($payment_data['email'], $subject, $message, $headers, $attachments);
    if ($admin_notice) {
        /* send an email notification to the admin */
        $admin_email = edd_get_admin_notice_emails();
        $admin_subject = apply_filters('edd_admin_purchase_notification_subject', __('New download purchase', 'edd'), $payment_id, $payment_data);
        $admin_message = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n";
        $admin_message .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n";
        $download_list = '';
        $downloads = maybe_unserialize($payment_data['downloads']);
        if (is_array($downloads)) {
            foreach ($downloads as $download) {
                $id = isset($payment_data['cart_details']) ? $download['id'] : $download;
                $download_list .= html_entity_decode(get_the_title($id), ENT_COMPAT, 'UTF-8') . "\n";
            }
        }
        $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true));
        $admin_message .= $download_list . "\n";
        $admin_message .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n";
        $admin_message .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($payment_data['amount'])), ENT_COMPAT, 'UTF-8') . "\n\n";
        $admin_message .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n";
        $admin_message .= __('Thank you', 'edd');
        $admin_message = apply_filters('edd_admin_purchase_notification', $admin_message, $payment_id, $payment_data);
        $admin_headers = apply_filters('edd_admin_purchase_notification_headers', array(), $payment_id, $payment_data);
        $admin_attachments = apply_filters('edd_admin_purchase_notification_attachments', array(), $payment_id, $payment_data);
        wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $admin_attachments);
    }
}
/**
 * Email the download link(s) and payment confirmation to the admin accounts for testing.
 *
 * @since 1.5
 * @global $edd_options Array of all the EDD Options
 * @return void
 */
function edd_email_test_purchase_receipt()
{
    global $edd_options;
    $default_email_body = __("Dear", "edd") . " {name},\n\n";
    $default_email_body .= __("Thank you for your purchase. Please click on the link(s) below to download your files.", "edd") . "\n\n";
    $default_email_body .= "{download_list}\n\n";
    $default_email_body .= "{sitename}";
    $email = isset($edd_options['purchase_receipt']) ? $edd_options['purchase_receipt'] : $default_email_body;
    $message = edd_get_email_body_header();
    $message .= apply_filters('edd_purchase_receipt', edd_email_preview_templage_tags($email), 0, array());
    $message .= edd_get_email_body_footer();
    $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
    $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
    $subject = apply_filters('edd_purchase_subject', isset($edd_options['purchase_subject']) ? trim($edd_options['purchase_subject']) : __('Purchase Receipt', 'edd'), 0);
    $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
    $headers .= "Reply-To: " . $from_email . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=utf-8\r\n";
    $headers = apply_filters('edd_test_purchase_headers', $headers);
    wp_mail(edd_get_admin_notice_emails(), $subject, $message, $headers);
}
 private function mail_results($result)
 {
     global $edd_options;
     /* Send an email notification to the admin */
     $admin_email = edd_get_admin_notice_emails();
     $admin_message = edd_get_email_body_header();
     $admin_message .= __('Hello! A payment was just triggered to mass pay all vendors their due commission.', 'eddc') . PHP_EOL . PHP_EOL;
     $admin_message .= sprintf(__('Payment status: %s.', 'eddc'), $result['status']) . PHP_EOL;
     $admin_message .= sprintf(__('Payment message: %s.', 'eddc'), $result['msg']) . PHP_EOL;
     if (!empty($result['total'])) {
         $admin_message .= sprintf(__('Payment total: %s.', 'eddc'), $result['total']);
     }
     $admin_message .= edd_get_email_body_footer();
     $admin_subject = __('EDD Commissions: Mass payments for vendors update', 'eddc');
     $admin_subject = apply_filters('eddc_admin_commissions_payout_notification_subject', $admin_subject, $result);
     $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
     $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
     $admin_headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
     $admin_headers .= "Reply-To: " . $from_email . "\r\n";
     $admin_headers .= "MIME-Version: 1.0\r\n";
     $admin_headers .= "Content-Type: text/html; charset=utf-8\r\n";
     $admin_headers .= apply_filters('eddc_admin_commissions_payout_notification_headers', $admin_headers, $result);
     $sent = wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers);
     return $sent;
 }
示例#4
0
/**
 * Email the product update test email to the admin account
 *
 * @global $edd_options Array of all the EDD Options
 * @return void
 */
function edd_pup_test_email($email_id, $to = null)
{
    $email = get_post($email_id);
    $emailmeta = get_post_custom($email_id);
    $from_name = isset($emailmeta['_edd_pup_from_name'][0]) ? $emailmeta['_edd_pup_from_name'][0] : get_bloginfo('name');
    $from_email = isset($emailmeta['_edd_pup_from_email'][0]) ? $emailmeta['_edd_pup_from_email'][0] : get_option('admin_email');
    $subject = apply_filters('edd_pup_test_subject', isset($email->post_excerpt) ? trim($email->post_excerpt) : __('(no subject)', 'edd-pup'), 0);
    $subject = strip_tags(edd_email_preview_template_tags($subject));
    $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
    $headers .= "Reply-To: " . $from_email . "\r\n";
    $headers .= "Content-Type: text/html; charset=utf-8\r\n";
    $headers = apply_filters('edd_pup_test_headers', $headers);
    add_filter('edd_email_template', 'edd_pup_template');
    if (version_compare(get_option('edd_version'), '2.1') >= 0) {
        $edd_emails = new EDD_emails();
        $message = edd_email_preview_template_tags($email->post_content);
        $edd_emails->__set('from_name', $from_name);
        $edd_emails->__set('from_address', $from_email);
        // Send the email
        foreach ($to as $recipient) {
            $edd_emails->send($recipient, $subject, $message);
        }
        //$edd_emails = new EDD_Emails;
        //$message = $edd_emails->build_email( edd_email_preview_template_tags( $email->post_content ) );
    } else {
        $message = edd_get_email_body_header();
        $message .= apply_filters('edd_pup_test_message', edd_apply_email_template($email->post_content, null, null), $email_id);
        $message .= edd_get_email_body_footer();
        foreach ($to as $recipient) {
            wp_mail($recipient, $subject, $message, $headers);
        }
    }
    return $to;
}
/**
 * Send test email
 * 
 * @todo remove edd_email_preview_templage_tags() function check when EDD supports it
 * @since 1.0
*/
function edd_ppe_test_purchase_receipt($receipt_id = 0)
{
    global $pagenow, $typenow;
    $receipt = edd_ppe_get_receipt($receipt_id);
    // default email subject
    $default_email_subject = __("Thanks for purchasing {download_name}", "edd-ppe");
    // default email body
    $default_email_body = __("Dear", "edd-ppe") . " {name},\n\n";
    $default_email_body .= __("Thank you for purchasing {download_name}. Please click on the link(s) below to download your files.", "edd-ppe") . "\n\n";
    $default_email_body .= "{download_list}\n\n";
    $default_email_body .= "{sitename}";
    // use new EDD 2.1 Email class
    if (class_exists('EDD_Emails')) {
        // we're on the main screen of edd receipts, get relevant subject and body for test email
        if (isset($_GET['page']) && 'edd-receipts' == $_GET['page'] && 'download' == $typenow && in_array($pagenow, array('edit.php'))) {
            $subject = $receipt->post_excerpt ? $receipt->post_excerpt : $default_email_subject;
            $body = $receipt->post_content ? $receipt->post_content : $default_email_body;
        }
        // run subject through email_preview_subject_template_tags() function
        $subject = apply_filters('edd_ppe_purchase_receipt_subject', edd_ppe_email_preview_subject_template_tags($subject, $receipt_id), 0, array());
        // run subject through the standard EDD email tag function
        $subject = edd_do_email_tags($subject, 0);
        // message
        $message = apply_filters('edd_ppe_purchase_body', $receipt->post_content ? $receipt->post_content : $default_email_body);
        $message = edd_email_preview_template_tags($body, 0);
        // add download name as email heading. Off by default
        // will introduce a checkbox in admin to turn all headings on rather than turn them on now which may mess up emails
        if (apply_filters('edd_ppe_email_heading', false)) {
            EDD()->emails->__set('heading', get_the_title($product_id));
        }
        EDD()->emails->send(edd_get_admin_notice_emails(), $subject, $message);
    } else {
        // we're on the main screen of edd receipts, get relevant subject and body for test email
        if (isset($_GET['page']) && 'edd-receipts' == $_GET['page'] && 'download' == $typenow && in_array($pagenow, array('edit.php'))) {
            $subject = $receipt->post_excerpt ? $receipt->post_excerpt : $default_email_subject;
            $body = $receipt->post_content ? $receipt->post_content : $default_email_body;
        }
        // run subject through email_preview_subject_template_tags() function
        $subject = apply_filters('edd_ppe_purchase_receipt_subject', edd_ppe_email_preview_subject_template_tags($subject, $receipt_id), 0, array());
        $message = edd_get_email_body_header();
        // will remove the edd_email_preview_templage_tags() function when new EDD version is released
        $message .= apply_filters('edd_purchase_receipt', function_exists('edd_email_preview_template_tags') ? edd_email_preview_template_tags($body) : edd_email_preview_templage_tags($body), null, null);
        $message .= edd_get_email_body_footer();
        $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
        $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
        $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
        $headers .= "Reply-To: " . $from_email . "\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=utf-8\r\n";
        $headers = apply_filters('edd_test_purchase_headers', $headers);
        wp_mail(edd_get_admin_notice_emails(), $subject, $message, $headers);
    }
}
/**
 * Build the campaign expired email.
 *
 * Figure out who to send to, who it's from, etc.
 *
 * @since Astoundify Crowdfunding 1.6
 *
 * @param object $campaign
 * @return void
 */
function atcf_email_campaign_expiration($campaign)
{
    global $edd_options;
    $message = edd_get_email_body_header();
    $default_email_body = __('Dear Author', 'atcf') . "\n\n";
    $default_email_body .= sprintf(__('We would just like to let you know that your campaign has reached its end date. You can view your campaign by clicking <a href="%s">here</a>.', 'atcf'), get_permalink($campaign->ID));
    $message .= apply_filters('atcf_campaign_expiration_message', $default_email_body, $campaign);
    $message .= edd_get_email_body_footer();
    $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
    $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
    $subject = apply_filters('atcf_campaign_expiration_subject', __('Your campaign is complete!', 'atcf'), $campaign);
    $subject = edd_email_template_tags($subject, $payment_data, $payment_id);
    $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
    $headers .= "Reply-To: " . $from_email . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=utf-8\r\n";
    wp_mail($campaign->contact_email(), $subject, $message, $headers);
}