/** * Static method that is fired right after a donation is completed, sending the donation receipt. * * @param int $donation_id * @return boolean * @access public * @static * @since 1.0.0 */ public static function send_with_donation_id($donation_id) { if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) { return false; } if (!charitable_is_approved_status(get_post_status($donation_id))) { return false; } $donation = charitable_get_donation($donation_id); if (!is_object($donation) || 0 == count($donation->get_campaign_donations())) { return false; } if (!apply_filters('charitable_send_' . self::get_email_id(), true, $donation)) { return false; } $email = new Charitable_Email_Donation_Receipt(array('donation' => $donation)); /** * Don't resend the email. */ if ($email->is_sent_already($donation_id)) { return false; } $sent = $email->send(); /** * Log that the email was sent. */ if (apply_filters('charitable_log_email_send', true, self::get_email_id(), $email)) { $email->log($donation_id, $sent); } return true; }
/** * Static method that is fired right after a donation is completed, sending the donation receipt. * * @param int $donation_id * @return boolean * @access public * @static * @since 1.0.0 */ public static function send_with_donation_id($donation_id) { if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) { return false; } if (!Charitable_Donation::is_approved_status(get_post_status($donation_id))) { return false; } $email = new Charitable_Email_Donation_Receipt(array('donation' => new Charitable_Donation($donation_id))); $email->send(); return true; }
/** * Right after a donation is made, this sends the donation receipt to * the donor if the donation is pending AND it was made in offline mode. * * @param int $donation_id * @return boolean */ function en_send_donation_receipt_for_pending_offline($donation_id) { /* Verify that the email is enabled. */ if (!charitable_get_helper('emails')->is_enabled_email(Charitable_Email_Donation_Receipt::get_email_id())) { return false; } /* If the donation is not pending, stop here. */ if ('charitable-pending' != get_post_status($donation_id)) { return false; } /* If the donation was not made with the offline payment option, stop here. */ if ('offline' != get_post_meta($donation_id, 'donation_gateway', true)) { return false; } /* All three of those checks passed, so proceed with sending the email. */ $email = new Charitable_Email_Donation_Receipt(array('donation' => new Charitable_Donation($donation_id))); /* Don't resend the email. */ if ($email->is_sent_already($donation_id)) { return false; } $sent = $email->send(); /* Log that the email was sent. */ if (apply_filters('charitable_log_email_send', true, Charitable_Email_Donation_Receipt::get_email_id(), $email)) { $email->log($donation_id, $sent); } return true; }