예제 #1
0
 function trav_tour_send_confirmation_email($booking_no, $booking_pincode, $type = 'new', $subject = '', $description = '')
 {
     global $wpdb, $logo_url, $trav_options;
     $booking_data = trav_tour_get_booking_data($booking_no, $booking_pincode);
     if (!empty($booking_data)) {
         // server variables
         $admin_email = get_option('admin_email');
         $home_url = esc_url(home_url());
         $site_name = $_SERVER['SERVER_NAME'];
         $logo_url = esc_url($logo_url);
         $tour_book_conf_url = '';
         if (isset($trav_options['tour_booking_confirmation_page']) && !empty($trav_options['tour_booking_confirmation_page'])) {
             $tour_book_conf_url = trav_get_permalink_clang($trav_options['tour_booking_confirmation_page']);
         }
         $booking_data['tour_id'] = trav_tour_clang_id($booking_data['tour_id']);
         $st_data = trav_tour_get_schedule_type_data($booking_data['tour_id'], $booking_data['st_id']);
         $schedule_data = trav_tour_get_schedule_data($booking_data);
         // tour info
         $tour_name = get_the_title($booking_data['tour_id']);
         $tour_url = esc_url(trav_get_permalink_clang($booking_data['tour_id']));
         $tour_thumbnail = get_the_post_thumbnail($booking_data['tour_id'], 'list-thumb');
         $tour_address = get_post_meta($booking_data['tour_id'], 'trav_tour_address', true);
         $tour_city = trav_tour_get_city($booking_data['tour_id']);
         $tour_country = trav_tour_get_country($booking_data['tour_id']);
         $tour_phone = get_post_meta($booking_data['tour_id'], 'trav_tour_phone', true);
         $tour_email = get_post_meta($booking_data['tour_id'], 'trav_tour_email', true);
         $tour_duration = '';
         if (!empty($schedule_data) && $schedule_data['success'] == 1) {
             $tour_duration = $schedule_data['schedule_data']['duration'];
         }
         $tour_st_title = esc_html(trav_tour_get_schedule_type_title($booking_data['tour_id'], $booking_data['st_id']));
         $tour_st_description = esc_html($st_data['description']);
         $tour_st_time = esc_html($st_data['time']);
         if (empty($tour_address)) {
             $tour_address = $tour_city . ' ' . $tour_country;
         }
         $tour_date = date('l, F, j, Y', trav_strtotime($booking_data['tour_date']));
         // booking info
         $booking_no = $booking_data['booking_no'];
         $booking_pincode = $booking_data['pin_code'];
         $booking_adults = $booking_data['adults'];
         $booking_kids = $booking_data['kids'];
         $booking_total_price = esc_html(trav_get_price_field($booking_data['total_price'] * $booking_data['exchange_rate'], $booking_data['currency_code'], 0));
         $booking_deposit_price = esc_html($booking_data['deposit_price'] . $booking_data['currency_code']);
         $booking_deposit_paid = esc_html(empty($booking_data['deposit_paid']) ? 'No' : 'Yes');
         $booking_update_url = esc_url(add_query_arg(array('booking_no' => $booking_data['booking_no'], 'pin_code' => $booking_data['pin_code']), $tour_book_conf_url));
         // customer info
         $customer_first_name = $booking_data['first_name'];
         $customer_last_name = $booking_data['last_name'];
         $customer_email = $booking_data['email'];
         $customer_country_code = $booking_data['country_code'];
         $customer_phone = $booking_data['phone'];
         $customer_address = $booking_data['address'];
         $customer_city = $booking_data['city'];
         $customer_zip = $booking_data['zip'];
         $customer_country = $booking_data['country'];
         $customer_special_requirements = $booking_data['special_requirements'];
         $variables = array('home_url', 'site_name', 'logo_url', 'tour_name', 'tour_url', 'tour_thumbnail', 'tour_country', 'tour_city', 'tour_address', 'tour_phone', 'tour_email', 'tour_date', 'tour_duration', 'tour_st_title', 'tour_st_description', 'tour_st_time', 'booking_no', 'booking_pincode', 'booking_adults', 'booking_kids', 'booking_total_price', 'booking_deposit_price', 'booking_deposit_paid', 'booking_update_url', 'customer_first_name', 'customer_last_name', 'customer_email', 'customer_country_code', 'customer_phone', 'customer_address', 'customer_city', 'customer_zip', 'customer_country', 'customer_special_requirements');
         if (empty($subject)) {
             if ($type == 'new') {
                 $subject = empty($trav_options['tour_confirm_email_subject']) ? 'Booking Confirmation Email Subject' : $trav_options['tour_confirm_email_subject'];
             } elseif ($type == 'update') {
                 $subject = empty($trav_options['tour_update_email_subject']) ? 'Booking Updated Email Subject' : $trav_options['tour_update_email_subject'];
             } elseif ($type == 'cancel') {
                 $subject = empty($trav_options['tour_cancel_email_subject']) ? 'Booking Canceled Email Subject' : $trav_options['tour_cancel_email_subject'];
             }
         }
         if (empty($description)) {
             if ($type == 'new') {
                 $description = empty($trav_options['tour_confirm_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['tour_confirm_email_description'];
             } elseif ($type == 'update') {
                 $description = empty($trav_options['tour_update_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['tour_update_email_description'];
             } elseif ($type == 'cancel') {
                 $description = empty($trav_options['tour_cancel_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['tour_cancel_email_description'];
             }
         }
         foreach ($variables as $variable) {
             $subject = str_replace("[" . $variable . "]", ${$variable}, $subject);
             $description = str_replace("[" . $variable . "]", ${$variable}, $description);
         }
         $mail_sent = trav_send_mail($site_name, $admin_email, $customer_email, $subject, $description);
         /* mailing function to business owner */
         $bowner_address = '';
         if (!empty($trav_options['tour_booked_notify_bowner'])) {
             if ($type == 'new') {
                 $subject = empty($trav_options['tour_bowner_email_subject']) ? 'You received a booking' : $trav_options['tour_bowner_email_subject'];
                 $description = empty($trav_options['tour_bowner_email_description']) ? 'Booking Details' : $trav_options['tour_bowner_email_description'];
             } elseif ($type == 'update') {
                 $subject = empty($trav_options['tour_update_bowner_email_subject']) ? 'A booking is updated' : $trav_options['tour_update_bowner_email_subject'];
                 $description = empty($trav_options['tour_update_bowner_email_description']) ? 'Booking Details' : $trav_options['tour_update_bowner_email_description'];
             } elseif ($type == 'cancel') {
                 $subject = empty($trav_options['tour_cancel_bowner_email_subject']) ? 'A booking is canceled' : $trav_options['tour_cancel_bowner_email_subject'];
                 $description = empty($trav_options['tour_cancel_bowner_email_description']) ? 'Booking Details' : $trav_options['tour_cancel_bowner_email_description'];
             }
             foreach ($variables as $variable) {
                 $subject = str_replace("[" . $variable . "]", ${$variable}, $subject);
                 $description = str_replace("[" . $variable . "]", ${$variable}, $description);
             }
             if (!empty($tour_email)) {
                 $bowner_address = $tour_email;
             } else {
                 $post_author_id = get_post_field('post_author', $booking_data['tour_id']);
                 $bowner = get_user_by('id', $post_author_id);
                 if (!empty($bowner)) {
                     $bowner_address = $bowner->user_email;
                 }
             }
             if (!empty($bowner_address)) {
                 trav_send_mail($site_name, $admin_email, $bowner_address, $subject, $description);
             }
         }
         /* mailing function to admin */
         if (!empty($trav_options['tour_booked_notify_admin'])) {
             if ($bowner_address != $admin_email) {
                 if ($type == 'new') {
                     $subject = empty($trav_options['tour_admin_email_subject']) ? 'You received a booking' : $trav_options['tour_admin_email_subject'];
                     $description = empty($trav_options['tour_admin_email_description']) ? 'Booking Details' : $trav_options['tour_admin_email_description'];
                 } elseif ($type == 'update') {
                     $subject = empty($trav_options['tour_update_admin_email_subject']) ? 'A booking is updated' : $trav_options['tour_update_admin_email_subject'];
                     $description = empty($trav_options['tour_update_admin_email_description']) ? 'Booking Details' : $trav_options['tour_update_admin_email_description'];
                 } elseif ($type == 'cancel') {
                     $subject = empty($trav_options['tour_cancel_admin_email_subject']) ? 'A booking is canceled' : $trav_options['tour_cancel_admin_email_subject'];
                     $description = empty($trav_options['tour_cancel_admin_email_description']) ? 'Booking Details' : $trav_options['tour_cancel_admin_email_description'];
                 }
                 foreach ($variables as $variable) {
                     $subject = str_replace("[" . $variable . "]", ${$variable}, $subject);
                     $description = str_replace("[" . $variable . "]", ${$variable}, $description);
                 }
                 trav_send_mail($site_name, $admin_email, $admin_email, $subject, $description);
             }
         }
         return true;
     }
     return false;
 }
<?php

/**
 * Tour Booking Confirmation Template
 */
global $trav_options, $wpdb, $logo_url;
global $booking_data, $tour_id, $st_id, $deposit_rate;
if (!isset($_REQUEST['booking_no']) || !isset($_REQUEST['pin_code'])) {
    do_action('trav_tour_conf_wrong_data');
    exit;
}
if (!($booking_data = trav_tour_get_booking_data($_REQUEST['booking_no'], $_REQUEST['pin_code']))) {
    do_action('trav_tour_conf_wrong_data');
    exit;
}
$tour_id = trav_tour_clang_id($booking_data['tour_id']);
$st_id = $booking_data['st_id'];
$deposit_rate = get_post_meta($tour_id, 'trav_tour_security_deposit', true);
$deposit_rate = empty($deposit_rate) ? 0 : $deposit_rate;
$tour_date = trav_tophptime($booking_data['tour_date']);
// if deposit is required and it is not paid process payment
if (!empty($deposit_rate) && empty($booking_data['deposit_paid'])) {
    // init payment variables
    $ItemName = '';
    if ($deposit_rate < 100) {
        $ItemName = sprintf(__('Deposit(%d%%) for ', 'trav'), $deposit_rate);
    } else {
        $ItemName = __('Deposit for ', 'trav');
    }
    $ItemName .= get_the_title($tour_id) . ' ' . trav_tour_get_schedule_type_title($tour_id, $st_id);
    $payment_data = array();