function ct_hotel_generate_conf_mail($order, $type = 'new') { global $wpdb, $ct_options; $order_data = $order->get_order_info(); if (!empty($order_data)) { // server variables $admin_email = get_option('admin_email'); $home_url = esc_url(home_url('/')); $site_name = $_SERVER['SERVER_NAME']; $logo_url = esc_url(ct_logo_url()); $order_data['hotel_id'] = ct_hotel_clang_id($order_data['post_id']); // hotel info $hotel_name = get_the_title($order_data['hotel_id']); $hotel_url = esc_url(ct_get_permalink_clang($order_data['hotel_id'])); $hotel_thumbnail = get_the_post_thumbnail($order_data['hotel_id'], 'medium'); $hotel_address = get_post_meta($order_data['hotel_id'], 'ct_hotel_address', true); $hotel_email = get_post_meta($order_data['hotel_id'], 'ct_hotel_email', true); $hotel_phone = get_post_meta($order_data['hotel_id'], 'ct_hotel_phone', true); // room info $booking_rooms = '<table><tbody><tr><th>' . esc_html__('Room Name', 'citytours') . '</th><th>' . esc_html__('Rooms', 'citytours') . '</th><th>' . esc_html__('Adults', 'citytours') . '</th><th>' . esc_html__('Kids', 'citytours') . '</th><th>' . esc_html__('Total Price', 'citytours') . '</th></tr>'; $rooms_booking_data = $order->get_rooms(); if (!empty($rooms_booking_data)) { foreach ($rooms_booking_data as $key => $room_data) { $room_type_id = ct_room_clang_id($room_data['room_type_id']); $room_type_title = esc_html(get_the_title($room_type_id)); $booking_rooms .= '<tr><td>' . $room_type_title . '</td><td>' . $room_data['rooms'] . '</td><td>' . $room_data['adults'] . '</td><td>' . $room_data['kids'] . '</td><td>' . $room_data['total_price'] . '</td></tr>'; } } $booking_rooms .= '</tbody></table>'; // services info $booking_services = '<table><tbody><tr><th>' . esc_html__('Service Name', 'citytours') . '</th><th>' . esc_html__('Total Price', 'citytours') . '</th></tr>'; $services_booking_data = $order->get_services(); if (!empty($services_booking_data)) { foreach ($services_booking_data as $key => $service_booking_data) { $service_data = ct_get_add_service($service_booking_data['add_service_id']); $service_total_price = $service_booking_data['total_price']; $booking_services .= '<tr><td>' . $service_data->title . '</td><td>' . $service_total_price . '</td></tr>'; } } $booking_services .= '</tbody></table>'; // booking info $date_from = new DateTime($order_data['date_from']); $date_to = new DateTime($order_data['date_to']); $number1 = $date_from->format('U'); $number2 = $date_to->format('U'); $booking_nights = ($number2 - $number1) / (3600 * 24); $booking_from_date = date('j F Y', strtotime($order_data['date_from'])); $booking_to_date = date('j F Y', strtotime($order_data['date_to'])); $booking_adults = $order_data['total_adults']; $booking_kids = $order_data['total_kids']; $booking_total_price = esc_html(ct_price($order_data['total_price'] * $order_data['exchange_rate'], $order_data['currency_code'], 0)); $booking_deposit_price = esc_html($order_data['deposit_price'] . $order_data['currency_code']); $booking_deposit_paid = esc_html(empty($order_data['deposit_paid']) ? 'No' : 'Yes'); $booking_no = $order_data['booking_no']; $booking_pincode = $order_data['pin_code']; // customer info $customer_first_name = $order_data['first_name']; $customer_last_name = $order_data['last_name']; $customer_email = $order_data['email']; $customer_country_code = $order_data['country']; $customer_phone = $order_data['phone']; $customer_address1 = $order_data['address1']; $customer_address2 = $order_data['address2']; $customer_city = $order_data['city']; $customer_zip = $order_data['zip']; $customer_country = $order_data['country']; $customer_special_requirements = $order_data['special_requirements']; $variables = array('home_url', 'site_name', 'logo_url', 'hotel_name', 'hotel_url', 'hotel_thumbnail', 'hotel_address', 'hotel_email', 'hotel_phone', 'booking_rooms', 'booking_services', 'booking_no', 'booking_pincode', 'booking_from_date', 'booking_to_date', 'booking_nights', 'booking_adults', 'booking_kids', 'booking_total_price', 'booking_deposit_paid', 'booking_deposit_price', 'customer_first_name', 'customer_last_name', 'customer_email', 'customer_country_code', 'customer_phone', 'customer_address1', 'customer_address2', 'customer_city', 'customer_zip', 'customer_country', 'customer_special_requirements'); if (empty($subject)) { $subject = empty($ct_options['hotel_confirm_email_subject']) ? 'Booking Confirmation Email Subject' : $ct_options['hotel_confirm_email_subject']; } if (empty($description)) { $description = empty($ct_options['hotel_confirm_email_description']) ? 'Booking Confirmation Email Description' : $ct_options['hotel_confirm_email_description']; } foreach ($variables as $variable) { $subject = str_replace("[" . $variable . "]", ${$variable}, $subject); $description = str_replace("[" . $variable . "]", ${$variable}, $description); } $mail_sent = ct_send_mail($site_name, $admin_email, $customer_email, $subject, $description); /* mailing function to admin */ if (!empty($ct_options['hotel_booked_notify_admin'])) { $subject = empty($ct_options['hotel_admin_email_subject']) ? 'You received a booking' : $ct_options['hotel_admin_email_subject']; $description = empty($ct_options['hotel_admin_email_description']) ? 'Booking Details' : $ct_options['hotel_admin_email_description']; foreach ($variables as $variable) { $subject = str_replace("[" . $variable . "]", ${$variable}, $subject); $description = str_replace("[" . $variable . "]", ${$variable}, $description); } ct_send_mail($site_name, $admin_email, $admin_email, $subject, $description); } return true; } return false; }
</td> </tr> <?php } } ?> <?php $order_services = $order->get_services(); if (!empty($order_services)) { ?> <?php foreach ($order_services as $order_service) { ?> <?php $service_data = ct_get_add_service($order_service['add_service_id']); ?> <tr> <td class=""><?php echo esc_html($order_service['add_service_id']); ?> </td> <td class="text-center"><?php echo esc_html($service_data->title); ?> </td> <td class="text-right"><?php echo ct_price($order_service['total_price']); ?> </td> </tr>