/** * Email the download link(s) and payment confirmation to the buyer in a * customizable Purchase Receipt * * @since 1.0 * @param int $payment_id Payment ID * @param bool $admin_notice Whether to send the admin email notification or not (default: true) * @return void */ function edd_email_purchase_receipt($payment_id, $admin_notice = true) { $payment_data = edd_get_payment_meta($payment_id); $from_name = edd_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_name = apply_filters('edd_purchase_from_name', $from_name, $payment_id, $payment_data); $from_email = edd_get_option('from_email', get_bloginfo('admin_email')); $from_email = apply_filters('edd_purchase_from_address', $from_email, $payment_id, $payment_data); $to_email = edd_get_payment_user_email($payment_id); $subject = edd_get_option('purchase_subject', __('Purchase Receipt', 'edd')); $subject = apply_filters('edd_purchase_subject', wp_strip_all_tags($subject), $payment_id); $subject = edd_do_email_tags($subject, $payment_id); $heading = edd_get_option('purchase_heading', __('Purchase Receipt', 'edd')); $heading = apply_filters('edd_purchase_heading', $heading, $payment_id, $payment_data); $attachments = apply_filters('edd_receipt_attachments', array(), $payment_id, $payment_data); $message = edd_do_email_tags(edd_get_email_body_content($payment_id, $payment_data), $payment_id); $emails = EDD()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('heading', $heading); $headers = apply_filters('edd_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); $emails->__set('headers', $headers); $emails->send($to_email, $subject, $message, $attachments); if ($admin_notice && !edd_admin_notices_disabled($payment_id)) { do_action('edd_admin_sale_notice', $payment_id, $payment_data); } }
/** * Helper Functions */ function wc_edd_email_purchase_receipt($payment_id, $download_id) { $payment_data = edd_get_payment_meta($payment_id); $download = get_post($download_id); $license = edd_software_licensing()->get_license_by_purchase($payment_id, $download_id); $from_name = edd_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_name = apply_filters('edd_purchase_from_name', $from_name, $payment_id, $payment_data); $from_email = edd_get_option('from_email', get_bloginfo('admin_email')); $from_email = apply_filters('edd_purchase_from_address', $from_email, $payment_id, $payment_data); $to_email = edd_get_payment_user_email($payment_id); $subject = edd_get_option('purchase_subject', __('New License Key', 'edd')); $subject = apply_filters('edd_purchase_subject', wp_strip_all_tags($subject), $payment_id); $subject = edd_do_email_tags($subject, $payment_id); $message = "Dear " . edd_email_tag_first_name($payment_id) . ",\n\n"; $message .= "As you have updated " . $download->post_title . ", please use following new license key to continue getting future updates: \n\n"; $message .= "License Key : " . edd_software_licensing()->get_license_key($license->ID) . "\n\n"; $message .= "Sorry for inconvenience."; $emails = EDD()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('heading', __('Purchase Receipt', 'edd')); $headers = apply_filters('edd_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); $emails->__set('headers', $headers); $emails->send($to_email, $subject, $message, array()); if ($admin_notice && !edd_admin_notices_disabled($payment_id)) { do_action('edd_admin_sale_notice', $payment_id, $payment_data); } }
/** * Email the download link(s) and payment confirmation to the buyer in a * customizable Purchase Receipt * * @since 1.0 * @param int $payment_id Payment ID * @param bool $admin_notice Whether to send the admin email notification or not (default: true) * @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']); $email = edd_get_payment_user_email($payment_id); 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 = $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 = apply_filters('edd_purchase_subject', isset($edd_options['purchase_subject']) ? trim($edd_options['purchase_subject']) : __('Purchase Receipt', 'edd'), $payment_id); $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"; $headers = apply_filters('edd_receipt_headers', $headers, $payment_id, $payment_data); // Allow add-ons to add file attachments $attachments = apply_filters('edd_receipt_attachments', array(), $payment_id, $payment_data); wp_mail($email, $subject, $message, $headers, $attachments); if ($admin_notice && !edd_admin_notices_disabled()) { do_action('edd_admin_sale_notice', $payment_id, $payment_data); } }
/** * Our custom email function * * @since 1.0.0 * @param string $type Whether this is a user- or admin-generated email * @param int $id The ID of a payment if user email, or the wallet user if admin email * @param int $item The wallet line item we are sending this for * @return void */ function edd_wallet_send_email($type = 'user', $id = 0, $item = null) { $from_name = edd_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_email = edd_get_option('from_email', get_bloginfo('admin_email')); if ($type == 'user') { $payment_data = edd_get_payment_meta($id); if (!edd_admin_notices_disabled($id)) { edd_wallet_send_admin_email($id, $payment_data); } $from_name = apply_filters('edd_purchase_from_name', $from_name, $id, $payment_data); $from_email = apply_filters('edd_purchase_from_address', $from_email, $id, $payment_data); $to_email = edd_get_payment_user_email($id); $subject = edd_get_option('wallet_receipt_subject', __('Receipt for deposit', 'edd-wallet')); $subject = apply_filters('edd_wallet_receipt_subject', wp_strip_all_tags($subject), $id); $subject = edd_wallet_do_email_tags($subject, $id); $message = edd_get_option('wallet_receipt', __('Dear', 'edd-wallet') . " {name},\n\n" . __('Thank you for your deposit. {value} has been added to your wallet.', 'edd-wallet') . "\n\n{sitename}"); $message = edd_wallet_do_email_tags($message, $id); } else { $user_data = get_userdata($id); $to_email = $user_data->user_email; if ($type == 'admin-deposit') { $subject = edd_get_option('wallet_admin_deposit_receipt_subject', __('Receipt for deposit', 'edd-wallet')); $subject = apply_filters('edd_wallet_admin_deposit_subject', wp_strip_all_tags($subject), $id); $subject = edd_wallet_do_email_tags($subject, $item); $message = edd_get_option('wallet_admin_deposit_receipt', __('Dear', 'edd-wallet') . " {name},\n\n" . __('The site admin has credited your wallet {value}.', 'edd-wallet') . "\n\n{sitename}"); $message = edd_wallet_do_email_tags($message, $item); } else { $subject = edd_get_option('wallet_admin_withdrawal_receipt_subject', __('Receipt for withdraw', 'edd-wallet')); $subject = apply_filters('edd_wallet_admin_withdrawal_subject', wp_strip_all_tags($subject), $id); $subject = edd_wallet_do_email_tags($subject, $item); $message = edd_get_option('wallet_admin_withdrawal_receipt', __('Dear', 'edd-wallet') . " {name},\n\n" . __('The site admin has deducted {value} from your wallet.', 'edd-wallet') . "\n\n{sitename}"); $message = edd_wallet_do_email_tags($message, $item); } } $emails = EDD()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->send($to_email, $subject, $message); }
/** * Disable standard purchase receipt, but only if all products purchased have custom emails configured * @since 1.0.1 */ function edd_ppe_disable_purchase_receipt($payment_id, $admin_notice = true) { global $edd_options; $payment_data = edd_get_payment_meta($payment_id); $cart_items = edd_get_payment_meta_cart_details($payment_id); foreach ($cart_items as $product) { $product_ids[] = $product['id']; } // make sure all of the downloads purchase exist as receipts if (isset($edd_options['edd_ppe_disable_purchase_receipt']) && count(array_intersect($product_ids, edd_ppe_get_active_receipts())) === count($product_ids)) { // prevents standard purchase receipt from firing remove_action('edd_complete_purchase', 'edd_trigger_purchase_receipt', 999, 1); //the above remove_action disables the admin notification, so let's get it going again if ($admin_notice && !edd_admin_notices_disabled($payment_id)) { do_action('edd_admin_sale_notice', $payment_id, $payment_data); } } }