Example #1
0
/**
 * Sale Notification Template Body
 *
 * @since  1.0
 *
 * @param int   $payment_id   Payment ID
 * @param array $payment_data Payment Data
 *
 * @return string $email_body Body of the email
 */
function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array())
{
    global $give_options;
    $user_info = maybe_unserialize($payment_data['user_info']);
    $email = give_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;
    }
    $gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
    $default_email_body = __('Hello', 'give') . "\n\n" . __('A donation has been made', 'give') . ".\n\n";
    $default_email_body .= sprintf(__('%s sold:', 'give'), give_get_forms_label_plural()) . "\n\n";
    $default_email_body .= __('Donor: ', 'give') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n";
    $default_email_body .= __('Amount: ', 'give') . " " . html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8') . "\n";
    $default_email_body .= __('Payment Method: ', 'give') . " " . $gateway . "\n\n";
    $default_email_body .= __('Thank you', 'give');
    $email = isset($give_options['donation_notification']) ? stripslashes($give_options['donation_notification']) : $default_email_body;
    $email_body = give_do_email_tags($email, $payment_id);
    return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
}
/**
 * Customize the "Pending" Offline donation notification subject for admins.
 *
 * Note: You can use template tags within the subject.
 *
 * @param $subject    The original subject
 * @param $payment_id The payment ID.
 *
 * @return string
 */
function my_custom_give_offline_pending_email_subject($subject, $payment_id)
{
    $new_subject = __('Testing 123 {fullname}', 'give');
    $admin_message = give_do_email_tags($new_subject, $payment_id);
    return $admin_message;
}
Example #3
0
/**
 * Sends the Admin Sale Notification Email
 *
 * @since 1.0
 *
 * @param int   $payment_id   Payment ID (default: 0)
 * @param array $payment_data Payment Meta and Data
 *
 * @return void
 */
function give_admin_email_notice($payment_id = 0, $payment_data = array())
{
    $payment_id = absint($payment_id);
    if (empty($payment_id)) {
        return;
    }
    if (!give_get_payment_by('id', $payment_id)) {
        return;
    }
    $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
    $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data);
    $from_email = give_get_option('from_email', get_bloginfo('admin_email'));
    $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data);
    $subject = give_get_option('donation_notification_subject', sprintf(__('New Donation - Payment #%1$s', 'give'), $payment_id));
    $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id);
    $subject = give_do_email_tags($subject, $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('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data);
    $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data);
    $message = give_get_donation_notification_body_content($payment_id, $payment_data);
    $emails = Give()->emails;
    $emails->__set('from_name', $from_name);
    $emails->__set('from_email', $from_email);
    $emails->__set('headers', $headers);
    $emails->__set('heading', __('New Donation!', 'give'));
    $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
}
Example #4
0
/**
 * Send Offline Donation Instructions
 *
 * @description Sends a notice to the donor with offline instructions; can be customized per form
 *
 * @param int $payment_id
 *
 * @since       1.0
 * @return void
 */
function give_offline_send_donor_instructions($payment_id = 0)
{
    $payment_data = give_get_payment_meta($payment_id);
    $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true);
    //Customize email content depending on whether the single form has been customized
    $email_content = give_get_option('global_offline_donation_email');
    if ($post_offline_customization_option === 'yes') {
        $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true);
    }
    $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
    $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data);
    $from_email = give_get_option('from_email', get_bloginfo('admin_email'));
    $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data);
    $to_email = give_get_payment_user_email($payment_id);
    $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give'));
    if ($post_offline_customization_option === 'yes') {
        $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true);
    }
    $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id);
    $subject = give_do_email_tags($subject, $payment_id);
    $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data);
    $message = give_do_email_tags($email_content, $payment_id);
    $emails = Give()->emails;
    $emails->__set('from_name', $from_name);
    $emails->__set('from_email', $from_email);
    $emails->__set('heading', __('Offline Donation Instructions', 'give'));
    $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
    $emails->__set('headers', $headers);
    $emails->send($to_email, $subject, $message, $attachments);
}
Example #5
0
/**
 * Send Offline Donation Admin Notice
 *
 * Sends a notice to site admins about the pending donation
 *
 * @since       1.0
 *
 * @param int $payment_id
 *
 * @return void
 *
 */
function give_offline_send_admin_notice($payment_id = 0)
{
    /* Send an email notification to the admin */
    $admin_email = give_get_admin_notice_emails();
    $user_info = give_get_payment_meta_user_info($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 = $user_info['email'];
    }
    $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)));
    $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id);
    $admin_message = esc_attr__('Dear Admin,', 'give') . "\n\n";
    $admin_message .= esc_attr__('An offline donation has been made on your website: ', 'give') . get_bloginfo('name') . ' ';
    $admin_message .= esc_attr__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give') . "\n\n";
    $admin_message .= '<strong>' . esc_attr__('Donor: ', 'give') . '</strong>' . '{fullname}' . "\n";
    $admin_message .= '<strong>' . esc_attr__('Amount: ', 'give') . '</strong>' . '{amount}' . "\n\n";
    $admin_message .= sprintf('<a href="%1$s">%2$s</a>', admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id), esc_html__('Click Here to View and/or Update Donation Details', 'give')) . "\n\n";
    $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
    $admin_message = give_do_email_tags($admin_message, $payment_id);
    $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
    $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
    //Send Email
    $emails = Give()->emails;
    if (!empty($admin_headers)) {
        $emails->__set('headers', $admin_headers);
    }
    $emails->send($admin_email, $admin_subject, $admin_message, $attachments);
}