public function show_donation_detail($donation_id) { $html = ""; $html .= "<table class='widefat'><tbody>\n"; $year = get_post_meta($donation_id, '_dgx_donate_year', true); $month = get_post_meta($donation_id, '_dgx_donate_month', true); $day = get_post_meta($donation_id, '_dgx_donate_day', true); $time = get_post_meta($donation_id, '_dgx_donate_time', true); $html .= "<tr>"; $html .= "<th>" . esc_html__('Date', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($month . "/" . $day . "/" . $year . " " . $time) . "</td></tr>\n"; $amount = get_post_meta($donation_id, '_dgx_donate_amount', true); $currency_code = dgx_donate_get_donation_currency_code($donation_id); $formatted_amount = dgx_donate_get_escaped_formatted_amount($amount, 2, $currency_code); $html .= "<tr>"; $html .= "<th>" . esc_html__('Amount', 'seamless-donations') . "</th>"; $html .= "<td>" . $formatted_amount . "</td></tr>\n"; $add_to_mailing_list = get_post_meta($donation_id, '_dgx_donate_add_to_mailing_list', true); if (!empty($add_to_mailing_list)) { $add_to_mailing_list = __('Yes', 'seamless-donations'); } else { $add_to_mailing_list = __('No', 'seamless-donations'); } $html .= "<tr><th>" . esc_html__('Add to Mailing List?', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($add_to_mailing_list) . "</td></tr>\n"; $anonymous = get_post_meta($donation_id, '_dgx_donate_anonymous', true); if (empty($anonymous)) { $anonymous = __('No', 'seamless-donations'); } else { $anonymous = __('Yes', 'seamless-donations'); } $html .= "<tr><th>" . esc_html__('Would like to remain anonymous?', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($anonymous) . "</td></tr>\n"; $fund_name = __('Undesignated', 'seamless-donations'); $designated = get_post_meta($donation_id, '_dgx_donate_designated', true); if (!empty($designated)) { $fund_name = get_post_meta($donation_id, '_dgx_donate_designated_fund', true); } $html .= "<tr><th>" . esc_html__('Designated Fund', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($fund_name) . "</td></tr>\n"; $employer_match = get_post_meta($donation_id, '_dgx_donate_employer_match', true); if (empty($employer_match)) { $employer_match_message = __('No', 'seamless-donations'); } else { $employer_match_message = __('Yes', 'seamless-donations'); } $html .= "<tr><th>" . esc_html__('Employer Match', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($employer_match_message) . "</td></tr>\n"; $employer_name = get_post_meta($donation_id, '_dgx_donate_employer_name', true); if (empty($employer_name)) { $employer_name_message = '-'; } else { $employer_name_message = $employer_name; } $html .= "<tr><th>" . esc_html__('Employer', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($employer_name_message) . "</td></tr>\n"; $occupation = get_post_meta($donation_id, '_dgx_donate_occupation', true); if (empty($occupation)) { $occupation_message = '-'; } else { $occupation_message = $occupation; } $html .= "<tr><th>" . esc_html__('Occupation', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($occupation_message) . "</td></tr>\n"; $donor_country = get_post_meta($donation_id, '_dgx_donate_donor_country', true); if ('GB' == $donor_country) { $uk_gift_aid = get_post_meta($donation_id, '_dgx_donate_uk_gift_aid', true); if (empty($uk_gift_aid)) { $uk_gift_aid_message = __('No', 'seamless-donations'); } else { $uk_gift_aid_message = __('Yes', 'seamless-donations'); } $html .= "<tr><th>" . esc_html__('UK Gift Aid', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($uk_gift_aid_message) . "</td></tr>\n"; } $tribute_gift_message = __('No', 'seamless-donations'); $tribute_gift = get_post_meta($donation_id, '_dgx_donate_tribute_gift', true); if (!empty($tribute_gift)) { $tribute_gift_message = __('Yes', 'seamless-donations') . " - "; $honoree_name = get_post_meta($donation_id, '_dgx_donate_honoree_name', true); $honor_by_email = get_post_meta($donation_id, '_dgx_donate_honor_by_email', true); $honoree_email_name = get_post_meta($donation_id, '_dgx_donate_honoree_email_name', true); $honoree_post_name = get_post_meta($donation_id, '_dgx_donate_honoree_post_name', true); $honoree_email = get_post_meta($donation_id, '_dgx_donate_honoree_email', true); $honoree_address = get_post_meta($donation_id, '_dgx_donate_honoree_address', true); $honoree_city = get_post_meta($donation_id, '_dgx_donate_honoree_city', true); $honoree_state = get_post_meta($donation_id, '_dgx_donate_honoree_state', true); $honoree_province = get_post_meta($donation_id, '_dgx_donate_honoree_province', true); $honoree_zip = get_post_meta($donation_id, '_dgx_donate_honoree_zip', true); $honoree_country = get_post_meta($donation_id, '_dgx_donate_honoree_country', true); $memorial_gift = get_post_meta($donation_id, '_dgx_donate_memorial_gift', true); if (empty($memorial_gift)) { $tribute_gift_message .= __('in honor of', 'seamless-donations') . ' '; } else { $tribute_gift_message .= __('in memory of', 'seamless-donations') . ' '; } $tribute_gift_message .= $honoree_name . "<br/><br/>"; if ('TRUE' == $honor_by_email) { $tribute_gift_message .= __('Send acknowledgement via email to', 'seamless-donations') . '<br/>'; $tribute_gift_message .= esc_html($honoree_email_name) . "<br/>"; $tribute_gift_message .= esc_html($honoree_email) . "<br/>"; } else { $tribute_gift_message .= __('Send acknowledgement via postal mail to', 'seamless-donations') . '<br/>'; $tribute_gift_message .= esc_html($honoree_post_name) . "<br/>"; $tribute_gift_message .= esc_html($honoree_address) . "<br/>"; if (!empty($honoree_city)) { $tribute_gift_message .= esc_html($honoree_city . " "); } if ('US' == $honoree_country) { $tribute_gift_message .= esc_html($honoree_state . " "); } else { if ('CA' == $honoree_country) { $tribute_gift_message .= esc_html($honoree_province . " "); } } if (dgx_donate_country_requires_postal_code($honoree_country)) { $tribute_gift_message .= esc_html(" " . $honoree_zip); } $tribute_gift_message .= "<br/>"; $countries = dgx_donate_get_countries(); $honoree_country_name = $countries[$honoree_country]; $tribute_gift_message .= esc_html($honoree_country_name) . "<br/><br/>"; } } $html .= "<tr>"; $html .= "<th>" . esc_html__('Tribute Gift', 'seamless-donations') . "</th>"; $html .= "<td>" . $tribute_gift_message . "</td></tr>\n"; $payment_method = get_post_meta($donation_id, '_dgx_donate_payment_method', true); $html .= "<tr><th>" . esc_html__('Payment Method', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($payment_method) . "</td></tr>\n"; $repeating = get_post_meta($donation_id, '_dgx_donate_repeating', true); $is_repeating_donation = !empty($repeating); if ($is_repeating_donation) { $repeatingText = __('Yes', 'seamless-donations'); } else { $repeatingText = __('No', 'seamless-donations'); } $html .= "<tr><th>" . esc_html__('Repeating', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($repeatingText) . "</td></tr>\n"; $session_id = get_post_meta($donation_id, '_dgx_donate_session_id', true); $html .= "<tr><th>" . esc_html__('Session ID', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($session_id) . "</td></tr>\n"; $transaction_id = get_post_meta($donation_id, '_dgx_donate_transaction_id', true); $html .= "<tr><th>" . esc_html__('Transaction ID', 'seamless-donations') . "</th>"; $html .= "<td>" . esc_html($transaction_id) . "</td></tr>\n"; $html .= "</tbody></table>\n"; if ($is_repeating_donation) { // Display links to related (same session ID) donations $related_donation_ids = get_donations_by_meta('_dgx_donate_session_id', $session_id, -1); // Unset this donation if present (it probably will be) if (($index = array_search($donation_id, $related_donation_ids)) !== false) { unset($related_donation_ids[$index]); } $html .= "<h3>" . esc_html__('Related Donations', 'seamless-donations') . "</h3>\n"; $html .= "<p class='description'>"; $html .= esc_html__('For repeating donations, displays a list of other donations in the series (subscription)', 'seamless-donations'); $html .= "</p>\n"; // Show the array $html .= "<table class='widefat'><tbody>\n"; if (count($related_donation_ids)) { $html .= "<tr>"; $html .= "<th>" . esc_html__('Date', 'seamless-donations') . "</th>"; $html .= "<th>" . esc_html__('Transaction ID', 'seamless-donations') . "</th></tr>"; foreach ((array) $related_donation_ids as $related_donation_id) { $year = get_post_meta($related_donation_id, '_dgx_donate_year', true); $month = get_post_meta($related_donation_id, '_dgx_donate_month', true); $day = get_post_meta($related_donation_id, '_dgx_donate_day', true); $time = get_post_meta($related_donation_id, '_dgx_donate_time', true); $donation_date = $month . "/" . $day . "/" . $year; $transaction_id = get_post_meta($related_donation_id, '_dgx_donate_transaction_id', true); $donation_detail = seamless_donations_get_donation_detail_link($related_donation_id); $html .= "<tr>"; $html .= "<td><a href='" . esc_url($donation_detail) . "'>" . esc_html($donation_date . " " . $time) . "</a></td>"; $html .= "<td>" . esc_html($transaction_id) . "</td></tr>\n"; } } else { $html .= "<tr>"; $html .= "<th>" . esc_html__('No related donations found', 'seamless-donations') . "</th>"; $html .= "</tr>\n"; } $html .= "</tbody></table>\n"; } return $html; }
public function setUp() { // get donor data $post_id = $_GET['post']; $first = get_post_meta($post_id, '_dgx_donate_donor_first_name', true); $last = get_post_meta($post_id, '_dgx_donate_donor_last_name', true); $email = get_post_meta($post_id, '_dgx_donate_donor_email', true); $donation_list = get_post_meta($post_id, '_dgx_donate_donor_donations', true); $my_donations = explode(',', $donation_list); $my_donations = array_values(array_filter($my_donations)); // remove empty elements from the array // now build the table $html = ""; if (count($my_donations) < 1) { $html .= "<p>" . esc_html__('No donations found.', 'seamless-donations') . "</p>"; } else { $html .= "<table class='widefat'><tbody>\n"; $html .= "<tr>"; $html .= "<th>" . esc_html__('Date', 'seamless-donations') . "</th>"; $html .= "<th>" . esc_html__('Fund', 'seamless-donations') . "</th>"; $html .= "<th>" . esc_html__('Amount', 'seamless-donations') . "</th>"; $html .= "</tr>\n"; $donor_total = 0; $donor_currency_codes = array(); foreach ((array) $my_donations as $donation_id) { $year = get_post_meta($donation_id, '_dgx_donate_year', true); $month = get_post_meta($donation_id, '_dgx_donate_month', true); $day = get_post_meta($donation_id, '_dgx_donate_day', true); $time = get_post_meta($donation_id, '_dgx_donate_time', true); $fund_name = __('Undesignated', 'seamless-donations'); $designated = get_post_meta($donation_id, '_dgx_donate_designated', true); if (!empty($designated)) { $fund_name = get_post_meta($donation_id, '_dgx_donate_designated_fund', true); } $amount = get_post_meta($donation_id, '_dgx_donate_amount', true); $donor_total = $donor_total + floatval($amount); $currency_code = dgx_donate_get_donation_currency_code($donation_id); $donor_currency_codes[$currency_code] = true; $formatted_amount = dgx_donate_get_escaped_formatted_amount($amount, 2, $currency_code); $donation_detail = seamless_donations_get_donation_detail_link($donation_id); $html .= "<tr><td><a href='" . esc_url($donation_detail) . "'>" . esc_html($year . "-" . $month . "- " . $day . " " . $time) . "</a></td>"; $html .= "<td>" . esc_html($fund_name) . "</td>"; $html .= "<td>" . $formatted_amount . "</td>"; $html .= "</tr>\n"; } if (count($donor_currency_codes) > 1) { $formatted_donor_total = "-"; } else { $formatted_donor_total = dgx_donate_get_escaped_formatted_amount($donor_total, 2, $currency_code); } $html .= "<tr>"; $html .= "<th> </th><th>" . esc_html__('Donor Total', 'seamless-donations') . "</th>"; $html .= "<td>" . $formatted_donor_total . "</td></tr>\n"; $html .= "</tbody></table>\n"; } $this->addSettingFields(array('field_id' => 'donor_info', 'type' => 'donor_info', 'before_field' => $html)); }
function dgx_donate_send_donation_notification($donationID) { $fromEmail = get_option('dgx_donate_reply_email'); $subject = "[Seamless Donations] " . __('A donation has been received', 'seamless-donations'); $body = __('A donation has been received. Here are some details about the donation.', 'seamless-donations') . "\n"; $body .= "\n"; $body .= "Donor:\n"; $firstName = get_post_meta($donationID, '_dgx_donate_donor_first_name', true); $lastName = get_post_meta($donationID, '_dgx_donate_donor_last_name', true); $city = get_post_meta($donationID, '_dgx_donate_donor_city', true); $state = get_post_meta($donationID, '_dgx_donate_donor_state', true); $zip = get_post_meta($donationID, '_dgx_donate_donor_zip', true); $donorEmail = get_post_meta($donationID, '_dgx_donate_donor_email', true); $body .= "{$firstName} {$lastName}\n"; $body .= "{$city} {$state} {$zip}\n"; $body .= "{$donorEmail}\n"; $body .= "\n"; $tributeGift = get_post_meta($donationID, '_dgx_donate_tribute_gift', true); if (!empty($tributeGift)) { $body .= __('NOTE: The donor is making this donation in honor of / in memory of someone.', 'seamless-donations') . " "; $body .= __('Please see the donation details (using the link below) for more information.', 'seamless-donations') . "\n"; $body .= "\n"; } $employer_match = get_post_meta($donationID, '_dgx_donate_employer_match', true); if (!empty($employer_match)) { $body .= __('NOTE: The donor is making this donation with an employer match.', 'seamless-donations') . " "; $body .= __('Please see the donation details (using the link below) for more information.', 'seamless-donations') . "\n"; $body .= "\n"; } $amount = get_post_meta($donationID, '_dgx_donate_amount', true); $currency_code = dgx_donate_get_donation_currency_code($donationID); $formattedDonationAmount = dgx_donate_get_plain_formatted_amount($amount, 2, $currency_code, true); $body .= __('Donation:', 'seamless-donations') . "\n"; $body .= __('Amount:', 'seamless-donations') . " {$formattedDonationAmount}\n"; $body .= "\n"; $body .= __('Click on the following link to view all details for this donation:', 'seamless-donations') . "\n"; $sd4_mode = get_option('dgx_donate_start_in_sd4_mode'); if ($sd4_mode == false) { $secureDonateLink = dgx_donate_get_donation_detail_link($donationID); } else { $secureDonateLink = seamless_donations_get_donation_detail_link($donationID); } $donateLink = str_replace("https:", "http:", $secureDonateLink); $body .= $donateLink; $body .= "\n"; // Loop on addresses $notifyEmails = get_option('dgx_donate_notify_emails'); $notifyEmailAr = explode(',', $notifyEmails); foreach ($notifyEmailAr as $notifyEmail) { $notifyEmail = trim($notifyEmail); if (!empty($notifyEmail)) { $headers = "From: {$fromEmail}\r\n"; $mail_sent = wp_mail($notifyEmail, $subject, $body, $headers); if (!$mail_sent) { dgx_donate_debug_log("Error: Could NOT send mail."); dgx_donate_debug_log("Subject: {$subject}"); dgx_donate_debug_log("To Email: {$notifyEmail}"); } } } }