コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: main.php プロジェクト: danipolo/agroturismomenorca
 function ct_process_payment($payment_data)
 {
     // $payment_data = array('item_name', 'item_number', 'item_desc', 'item_qty', 'item_price', 'item_total_price', 'grand_total', 'status', 'return_url', 'cancel_url', 'deposit_rate')
     global $ct_options;
     $success = 0;
     if (ct_is_paypal_enabled()) {
         // validation
         if (empty($ct_options['paypal_api_username']) || empty($ct_options['paypal_api_password']) || empty($ct_options['paypal_api_signature'])) {
             echo '<h5 class="alert alert-warning">Please check site paypal setting. <a href="' . admin_url('themes.php?page=CityTours') . '">' . admin_url('themes.php?page=CityTours') . '</a><span class="close"></span></h5>';
             return false;
         }
         $PayPalApiUsername = $ct_options['paypal_api_username'];
         $PayPalApiPassword = $ct_options['paypal_api_password'];
         $PayPalApiSignature = $ct_options['paypal_api_signature'];
         $PayPalMode = empty($ct_options['paypal_sandbox']) ? 'live' : 'sandbox';
         // SetExpressCheckOut
         if (!isset($_GET["token"]) || !isset($_GET["PayerID"])) {
             $padata = '&METHOD=SetExpressCheckout' . '&RETURNURL=' . urlencode($payment_data['return_url']) . '&CANCELURL=' . urlencode($payment_data['cancel_url']) . '&PAYMENTREQUEST_0_PAYMENTACTION=' . urlencode("SALE") . '&L_PAYMENTREQUEST_0_NAME0=' . urlencode($payment_data['item_name']) . '&L_PAYMENTREQUEST_0_NUMBER0=' . urlencode($payment_data['item_number']) . '&L_PAYMENTREQUEST_0_DESC0=' . urlencode($payment_data['item_desc']) . '&L_PAYMENTREQUEST_0_AMT0=' . urlencode($payment_data['item_price']) . '&L_PAYMENTREQUEST_0_QTY0=' . urlencode($payment_data['item_qty']) . '&NOSHIPPING=1' . '&SOLUTIONTYPE=Sole' . '&PAYMENTREQUEST_0_ITEMAMT=' . urlencode($payment_data['item_total_price']) . '&PAYMENTREQUEST_0_AMT=' . urlencode($payment_data['grand_total']) . '&PAYMENTREQUEST_0_CURRENCYCODE=' . urlencode($payment_data['currency']) . '&LOCALECODE=US' . '&LOGOIMG=' . ct_logo_url() . '&CARTBORDERCOLOR=FFFFFF' . '&ALLOWNOTE=1';
             //We need to execute the "SetExpressCheckOut" method to obtain paypal token
             $paypal = new CT_PayPal();
             $httpParsedResponseAr = $paypal->PPHttpPost('SetExpressCheckout', $padata, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
             //Respond according to message we receive from Paypal
             if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
                 //Redirect user to PayPal store with Token received.
                 $paypalmode = $PayPalMode == 'sandbox' ? '.sandbox' : '';
                 $paypalurl = 'https://www' . $paypalmode . '.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $httpParsedResponseAr["TOKEN"] . '';
                 header('Location: ' . $paypalurl);
                 exit;
             } else {
                 //Show error message
                 echo '<div class="alert alert-warning"><b>Error : </b>' . urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]) . '<span class="close"></span></div>';
                 echo '<pre>';
                 print_r($httpParsedResponseAr);
                 echo '</pre>';
                 exit;
             }
         }
         // DoExpressCheckOut
         if (isset($_GET["token"]) && isset($_GET["PayerID"])) {
             $token = $_GET["token"];
             $payer_id = $_GET["PayerID"];
             $padata = '&TOKEN=' . urlencode($token) . '&PAYERID=' . urlencode($payer_id) . '&PAYMENTREQUEST_0_PAYMENTACTION=' . urlencode("SALE") . '&L_PAYMENTREQUEST_0_NAME0=' . urlencode($payment_data['item_name']) . '&L_PAYMENTREQUEST_0_NUMBER0=' . urlencode($payment_data['item_number']) . '&L_PAYMENTREQUEST_0_DESC0=' . urlencode($payment_data['item_desc']) . '&L_PAYMENTREQUEST_0_AMT0=' . urlencode($payment_data['item_price']) . '&L_PAYMENTREQUEST_0_QTY0=' . urlencode($payment_data['item_qty']) . '&PAYMENTREQUEST_0_ITEMAMT=' . urlencode($payment_data['item_total_price']) . '&PAYMENTREQUEST_0_AMT=' . urlencode($payment_data['grand_total']) . '&PAYMENTREQUEST_0_CURRENCYCODE=' . urlencode($payment_data['currency']);
             //execute the "DoExpressCheckoutPayment" at this point to Receive payment from user.
             $paypal = new ct_PayPal();
             $httpParsedResponseAr = $paypal->PPHttpPost('DoExpressCheckoutPayment', $padata, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
             //Check if everything went ok..
             if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
                 /*if ( $payment_data['deposit_rate'] < 100 ) {
                 			echo '<div class="alert alert-success">' . __( 'Security Deposit Payment Received Successfully! Your Transaction ID : ', 'citytours' ) . urldecode($httpParsedResponseAr["PAYMENTINFO_0_TRANSACTIONID"]) . '<span class="close"></span></div>';
                 		} else {*/
                 echo '<div class="alert alert-success">' . __('Payment Received Successfully! Your Transaction ID : ', 'citytours') . urldecode($httpParsedResponseAr["PAYMENTINFO_0_TRANSACTIONID"]) . '<span class="close"></span></div>';
                 // }
                 $transation_id = urldecode($httpParsedResponseAr["PAYMENTINFO_0_TRANSACTIONID"]);
                 // GetTransactionDetails requires a Transaction ID, and GetExpressCheckoutDetails requires Token returned by SetExpressCheckOut
                 $padata = '&TOKEN=' . urlencode($token);
                 $paypal = new ct_PayPal();
                 $httpParsedResponseAr = $paypal->PPHttpPost('GetExpressCheckoutDetails', $padata, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
                 if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
                     $success = 1;
                     return array('success' => 1, 'method' => 'paypal', 'transaction_id' => $transation_id);
                 } else {
                     echo '<div class="alert alert-warning"><b>GetTransactionDetails failed:</b>' . urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]) . '<span class="close"></span></div>';
                     echo '<pre>';
                     print_r($httpParsedResponseAr);
                     echo '</pre>';
                     exit;
                 }
             } else {
                 echo '<div class="alert alert-warning"><b>Error : </b>' . urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]) . '<span class="close"></span></div>';
                 echo '<pre>';
                 print_r($httpParsedResponseAr);
                 echo '</pre>';
                 exit;
             }
         }
     }
     return false;
 }
コード例 #3
0
?>
						</ul>
					</div>
				</div><!-- End row -->
			</div><!-- End container-->
		</div><!-- End top line-->

		<div class="container">
			<div class="row">
				<div class="col-md-3 col-sm-3 col-xs-3">
					<div id="logo">
						<a href="<?php 
echo esc_url(home_url('/'));
?>
"><img src="<?php 
echo esc_url(ct_logo_url());
?>
" width="<?php 
echo esc_attr(ct_get_header_logo_width());
?>
" height="<?php 
echo esc_attr(ct_get_header_logo_height());
?>
" alt="City tours" data-retina="true" class="logo_normal"></a>
						<a href="<?php 
echo esc_url(home_url('/'));
?>
"><img src="<?php 
echo esc_url(ct_logo_sticky_url());
?>
" width="<?php