/**
  *
  *
  * @since 1.0.1
  * @update 1.1.7
  */
 static function get_payment_gateways_html($post_id = false)
 {
     $all = self::get_payment_gateways();
     if (is_array($all) and !empty($all)) {
         $i = 1;
         $available = array();
         foreach ($all as $key => $value) {
             if (method_exists($value, 'is_available') and $value->is_available()) {
                 if (!$post_id) {
                     $post_id = STCart::get_booking_id();
                 }
                 if ($value->is_available($post_id)) {
                     $available[] = $value;
                 }
             }
         }
         if (!empty($available)) {
             foreach ($available as $key => $value) {
                 echo "<div class='payment_gateway_item'>  ";
                 $value->html();
                 echo "</div>";
                 if ($i < count($available)) {
                     echo '<div class="st-hr text-center m20" >
                         <hr>
                         <span class="st-or">' . __('Or', ST_TEXTDOMAIN) . '</span>
                     </div>';
                 }
                 $i++;
             }
         }
     }
 }
 /**
  *
  *
  * @since 1.0.1
  * @update 1.0.9
  */
 static function get_payment_gateways_html()
 {
     $all = self::get_payment_gateways();
     if (is_array($all) and !empty($all)) {
         $i = 1;
         $available = array();
         foreach ($all as $key => $value) {
             if (method_exists($value, 'is_available') and $value->is_available()) {
                 if (st()->get_option('booking_modal', 'off') == 'on') {
                     $post_id = get_the_ID();
                 } else {
                     $post_id = STCart::get_first_id_items();
                 }
                 $is_payment_gateway = get_post_meta($post_id, 'is_meta_payment_gateway_' . $key, true);
                 if ($is_payment_gateway != "off") {
                     $available[] = $value;
                 }
             }
         }
         if (!empty($available)) {
             foreach ($available as $key => $value) {
                 echo "<div class='payment_gateway_item'>  ";
                 $value->html();
                 echo "</div>";
                 if ($i < count($available)) {
                     echo '<div class="st-hr text-center m20" >
                         <hr>
                         <span class="st-or">' . __('Or', ST_TEXTDOMAIN) . '</span>
                     </div>';
                 }
                 $i++;
             }
         }
     }
 }
Exemplo n.º 3
0
 function do_add_to_cart($array = array())
 {
     $default = array('item_id' => '', 'number_room' => 1, 'price' => '', 'check_in' => '', 'check_out' => '', 'adult' => 1, 'children' => 0);
     extract(wp_parse_args($array, $default));
     $data = array('check_in' => $check_in, 'check_out' => $check_out, 'currency' => TravelHelper::get_default_currency('symbol'), 'adult' => $adult, 'children' => $children);
     STCart::add_cart($item_id, $number_room, $price, $data);
 }
Exemplo n.º 4
0
 /**
  *
  *
  * @update 1.1.1
  * */
 function do_checkout($order_id)
 {
     update_post_meta($order_id, 'status', 'pending');
     $order_token = get_post_meta($order_id, 'order_token_code', true);
     //Destroy cart on success
     STCart::destroy_cart();
     $booking_success = STCart::get_success_link();
     do_action('st_email_after_booking', $order_id);
     do_action('st_booking_submit_form_success', $order_id);
     if ($order_token) {
         $array = array('order_token_code' => $order_token);
     } else {
         $array = array('order_code' => $order_id);
     }
     return array('status' => true, 'redirect' => add_query_arg($array, $booking_success));
 }
 public function _checkout_form_validate()
 {
     $cart = STCart::get_carts();
     if (is_array($cart) && count($cart)) {
         $cart_hotel = ValidateNormalCheckout::get_cart_data($cart, 'st_hotel');
         $validate_hotel = ValidateNormalCheckout::_validate_cart_hotel($cart_hotel);
         if (!$validate_hotel) {
             $message = $_SESSION['flash_validate_checkout'];
             STTemplate::set_message($message);
             return false;
         }
         $cart_rental = ValidateNormalCheckout::get_cart_data($cart, 'st_rental');
         $validate_rental = ValidateNormalCheckout::_validate_cart_rental($cart_rental);
         if (!$validate_rental) {
             $message = $_SESSION['flash_validate_checkout'];
             STTemplate::set_message($message);
             return false;
         }
     }
     return true;
 }
Exemplo n.º 6
0
 function do_add_to_cart($array = array())
 {
     $form_validate = true;
     if (empty($array)) {
         $array = STInput::post();
     }
     $default = array('item_id' => '', 'number_room' => 1, 'price' => '', 'start' => '', 'end' => '', 'adult' => 1, 'children' => 0);
     $array = wp_parse_args($array, $default);
     extract($array);
     $data = array('check_in' => $start, 'check_out' => $end, 'currency' => TravelHelper::get_default_currency('symbol'), 'adult' => $adult, 'children' => $children);
     //Validate available number
     $form_validate = $this->_add_cart_check_available($item_id, $data);
     if ($form_validate) {
         $form_validate = apply_filters('st_rental_add_cart_validate', $form_validate);
     }
     if ($form_validate) {
         STCart::add_cart($item_id, $number_room, $price, $data);
     }
     return $form_validate;
 }
Exemplo n.º 7
0
 * @since 1.0
 *
 * hotel booking form
 *
 * Created by ShineTheme
 *
 */
$checkout_fields = STCart::get_checkout_fields();
?>
<div class="clearfix">

    <div class="row">
        <?php 
if (!empty($checkout_fields)) {
    foreach ($checkout_fields as $key => $value) {
        echo STCart::get_checkout_field_html($key, $value);
    }
}
?>

    </div>
</div>

<?php 
do_action('st_after_checkout_fields', get_post_type(get_the_ID()));
?>

<div class="clearfix">
    <div class="row">
        <div class="col-sm-6">
            <?php 
        echo date(get_option('date_format'), strtotime($data['data']['check_in']));
        ?>
                    <?php 
    }
    ?>
                    <?php 
    if (isset($data['data']['check_out'])) {
        ?>
                    <?php 
        st_the_language('to');
        echo date(get_option('date_format'), strtotime($data['data']['check_out']));
        ?>
                    <?php 
    }
    ?>
</small>
                </p>
            </div>
            <div class="col-xs-3">
                <p class="text-right"><span class="text-lg">
                    <?php 
    $money = STCart::get_hotel_price($data['data'], $data['price'], $data['number']);
    echo TravelHelper::format_money($money);
    ?>
                </span>
                </p>
            </div>
        </div>
    </li>
    <?php 
}
Exemplo n.º 9
0
                                        <td class="text-left title"><?php 
    st_the_language('tax:');
    ?>
</td>
                                        <td class="text-right"><?php 
    echo TravelHelper::format_money($tax_money);
    ?>
</td>
                                    </tr>
                                <tr>
                                    <td class="text-left title"><?php 
    st_the_language('total:');
    ?>
</td>
                                    <td class="text-right"><?php 
    echo TravelHelper::format_money(STCart::get_total());
    ?>
</td>
                                </tr>
                            </table>
                        
                        </div> -->
                    </div>
                </div>
            </div>
        <?php 
}
?>

    </div>
Exemplo n.º 10
0
                            <td class="post-title page-title column-title">
                                <?php 
        if ($item_id) {
            echo "<a href='" . get_edit_post_link($item_id) . "' target='_blank'>" . get_the_title($item_id) . "</a>";
        }
        ?>
                            </td>
                            <td class="post-title page-title column-title">
                                <?php 
        echo get_post_meta($post_id, 'item_number', true);
        ?>
                            </td>
                            <td class="post-title page-title column-title">
                                <?php 
        $price = STCart::get_order_item_total($post_id, get_post_meta($order_id, 'st_tax', true));
        $currency = get_post_meta($order_id, 'st_currency', true);
        echo TravelHelper::format_money_raw($price, $currency);
        ?>
                            </td>
                            <td class="post-title page-title column-title">
                                <?php 
        echo date(get_option('date_format'), strtotime($value->post_date));
        ?>
                            </td>
                            <td class="post-title page-title column-title">
                                <?php 
        echo get_post_meta($order_id, 'status', true);
        ?>
                            </td>
                            <td class="post-title page-title column-title">
Exemplo n.º 11
0
<?php

/**
 * @package WordPress
 * @subpackage Traveler
 * @since 1.0
 *
 * Cars cart item html
 *
 * Created by ShineTheme
 *
 */
if (isset($item_id) and $item_id) {
    $item = STCart::find_item($item_id);
    $data_price_cars = $item['data']['data_price_cars'];
    $selected_equipments = isset($item['data']['selected_equipments']) ? $item['data']['selected_equipments'] : false;
    $pick_up_date = $data_price_cars->date_time->pick_up_date;
    $pick_up_time = $data_price_cars->date_time->pick_up_time;
    $drop_off_date = $data_price_cars->date_time->drop_off_date;
    $drop_off_time = $data_price_cars->date_time->drop_off_time;
    $total_time = $data_price_cars->date_time->total_time;
    $date = new DateTime($pick_up_date);
    $start = $date->format('m/d/Y') . ' ' . $pick_up_time;
    $start = strtotime($start);
    $date = new DateTime($drop_off_date);
    $end = $date->format('m/d/Y') . ' ' . $drop_off_time;
    $end = strtotime($end);
    $day = STCars::get_date_diff($start, $end);
    if (!empty($item['data']['discount'])) {
        $count_sale = $item['data']['discount'];
        $price_old = $item['data']['price_old'];
echo __('Item', ST_TEXTDOMAIN);
?>
                    </td>
                    <td style="border-left: 1px solid #bcbcbc;border-top: 1px solid #bcbcbc;border-bottom: 1px solid #bcbcbc;padding: 6px;background: #e4e4e4;border-right: 1px solid #bcbcbc;">
                        <?php 
echo __('Infomation', ST_TEXTDOMAIN);
?>
                    </td>
                </tr>
                <?php 
$total = 0;
$i = 0;
$i++;
$order_item_id = $order_id;
$object_id = get_post_meta($order_item_id, 'item_id', TRUE);
$total = STCart::get_order_item_total($order_id);
?>
                <tr>
                    <td style="padding: 6px;border-left: 1px solid #bcbcbc;border-bottom: 1px solid #bcbcbc;" valign="top" align="center" width="5%">
                        <?php 
echo esc_html($i);
?>
                    </td>
                    <td width="35%" style="vertical-align: top;padding: 6px;border-bottom:1px dashed #ccc;border-left: 1px solid #bcbcbc;border-bottom: 1px solid #bcbcbc;">
                        <?php 
echo get_the_post_thumbnail($object_id, array(360, 270, 'bfi_thumb' => TRUE), array('style' => 'max-width:100%;height:auto'));
?>
                    </td>
                    <td style="padding: 6px;vertical-align: top;border-bottom:1px dashed #ccc;border-left: 1px solid #bcbcbc;border-bottom: 1px solid #bcbcbc;border-right: 1px solid #bcbcbc;">
                        <p>
                            <strong><?php 
Exemplo n.º 13
0
 function do_add_to_cart()
 {
     $pass_validate = true;
     $item_id = STInput::request('item_id');
     $number = STInput::request('number');
     $discount = STInput::request('discount');
     if (!empty($discount)) {
         $price = STInput::request('price');
         $price = $price - $price * ($discount / 100);
         $data = array('discount' => $discount, 'price_old' => STInput::request('price'), 'price_sale' => $price);
     } else {
         $price = STInput::request('price');
     }
     $data['check_in'] = STInput::request('check_in');
     $data['check_out'] = STInput::request('check_out');
     $data['type_price'] = STInput::request('type_price');
     if ($data['type_price'] == 'people_price') {
         $prices = self::get_price_person($item_id);
         $data['adult_price'] = $prices['adult'];
         $data['child_price'] = $prices['child'];
         $data['discount'] = $prices['discount'];
         $data['adult_number'] = STInput::request('adult_number', 1);
         $data['child_number'] = STInput::request('children_number', 0);
     }
     if ($pass_validate) {
         $pass_validate = apply_filters('st_activity_add_cart_validate', $pass_validate);
     }
     if ($pass_validate) {
         STCart::add_cart($item_id, $number, $price, $data);
     }
     return $pass_validate;
 }
Exemplo n.º 14
0
 function do_add_to_cart()
 {
     $pass_validate = TRUE;
     $item_id = intval(STInput::request('item_id', ''));
     if ($item_id <= 0 || get_post_type($item_id) != 'st_hotel') {
         STTemplate::set_message(__('This hotel is not available.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $room_id = intval(STInput::request('room_id', ''));
     if ($room_id <= 0 || get_post_type($room_id) != 'hotel_room') {
         STTemplate::set_message(__('This room is not available.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $check_in = STInput::request('check_in', '');
     if (empty($check_in)) {
         STTemplate::set_message(__('Date is invalid', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $check_in = TravelHelper::convertDateFormat($check_in);
     $check_out = STInput::request('check_out', '');
     if (empty($check_out)) {
         STTemplate::set_message(__('Date is invalid', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $check_out = TravelHelper::convertDateFormat($check_out);
     $room_num_search = intval(STInput::request('room_num_search', ''));
     if ($room_num_search <= 0) {
         $room_num_search = 1;
     }
     $adult_number = intval(STInput::request('adult_number', ''));
     if ($adult_number <= 0) {
         $adult_number = 1;
     }
     $child_number = intval(STInput::request('child_number', ''));
     if ($child_number <= 0) {
         $child_number = 0;
     }
     $checkin_ymd = date('Y-m-d', strtotime($check_in));
     $checkout_ymd = date('Y-m-d', strtotime($check_out));
     if (!HotelHelper::check_day_cant_order($room_id, $checkin_ymd, $checkout_ymd, $room_num_search)) {
         STTemplate::set_message(sprintf(__('This room is not available from %s to %s.', ST_TEXTDOMAIN), $checkin_ymd, $checkout_ymd), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     if (!HotelHelper::_check_room_available($room_id, $checkin_ymd, $checkout_ymd, $room_num_search)) {
         STTemplate::set_message(__('This room is not available.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     if (strtotime($check_out) - strtotime($check_in) <= 0) {
         STTemplate::set_message(__('The check-out is later than the check-in.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $num_room = intval(get_post_meta($room_id, 'number_room', true));
     $adult = intval(get_post_meta($room_id, 'adult_number', true));
     $children = intval(get_post_meta($room_id, 'children_number', true));
     if ($room_num_search > $num_room) {
         STTemplate::set_message(__('Max of rooms are incorrect.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     if ($adult_number > $adult) {
         STTemplate::set_message(sprintf(__('Max of adults is %d people.', ST_TEXTDOMAIN), $adult), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     if ($child_number > $children) {
         STTemplate::set_message(__('Number of children in the room are incorrect.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $today = date('m/d/Y');
     $period = TravelHelper::dateDiff($today, $check_in);
     $booking_min_day = intval(get_post_meta($item_id, 'min_book_room', true));
     $compare = TravelHelper::dateCompare($today, $check_in);
     $booking_period = get_post_meta($item_id, 'hotel_booking_period', true);
     if (empty($booking_period) || $booking_period <= 0) {
         $booking_period = 0;
     }
     if ($compare < 0) {
         STTemplate::set_message(__('You can not set check-in date in the past', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     if ($period < $booking_period) {
         STTemplate::set_message(sprintf(__('This hotel allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     if ($booking_min_day and $booking_min_day > TravelHelper::dateDiff($check_in, $check_out)) {
         STTemplate::set_message(sprintf(__('Please booking at least %d day(s)', ST_TEXTDOMAIN), $booking_min_day), 'danger');
         $pass_validate = false;
         return false;
     }
     $item_price = floatval(get_post_meta($room_id, 'price', true));
     // Extra price added in the new version 1.1.9
     $extras = STInput::request('extra_price', array());
     $numberday = TravelHelper::dateDiff($check_in, $check_out);
     $extra_price = STPrice::getExtraPrice($extras, $room_num_search, $numberday);
     $sale_price = STPrice::getRoomPrice($room_id, strtotime($check_in), strtotime($check_out), $room_num_search);
     $discount_rate = STPrice::get_discount_rate($room_id, strtotime($check_in));
     $data = array('item_price' => $item_price, 'ori_price' => $sale_price + $extra_price, 'check_in' => $check_in, 'check_out' => $check_out, 'room_num_search' => $room_num_search, 'room_id' => $room_id, 'adult_number' => $adult_number, 'child_number' => $child_number, 'extras' => $extras, 'extra_price' => $extra_price, 'commission' => TravelHelper::get_commission(), 'discount_rate' => $discount_rate);
     if ($pass_validate) {
         $pass_validate = apply_filters('st_hotel_add_cart_validate', $pass_validate, $data);
     }
     if ($pass_validate) {
         STCart::add_cart($item_id, $room_num_search, $sale_price + $extra_price, $data);
     }
     return $pass_validate;
 }
Exemplo n.º 15
0
 function do_add_to_cart()
 {
     $form_validate = TRUE;
     $item_id = intval(STInput::request('item_id', ''));
     if ($item_id <= 0 || get_post_type($item_id) != 'st_rental') {
         STTemplate::set_message(__('This rental is not available.', ST_TEXTDOMAIN), 'danger');
         $form_validate = FALSE;
         return false;
     }
     $check_in = STInput::request('start', '');
     if (empty($check_in)) {
         STTemplate::set_message(__('The check in field is not empty.', ST_TEXTDOMAIN), 'danger');
         $form_validate = FALSE;
         return false;
     }
     $check_in = TravelHelper::convertDateFormat($check_in);
     $check_out = STInput::request('end', '');
     if (empty($check_out)) {
         STTemplate::set_message(__('The check out field is not empty.', ST_TEXTDOMAIN), 'danger');
         $form_validate = FALSE;
         return false;
     }
     $check_out = TravelHelper::convertDateFormat($check_out);
     $today = date('m/d/Y');
     $booking_period = get_post_meta($item_id, 'rentals_booking_period', true);
     if (empty($booking_period) || $booking_period <= 0) {
         $booking_period = 0;
     }
     $period = TravelHelper::dateDiff($today, $check_in);
     $compare = TravelHelper::dateCompare($today, $check_in);
     if ($compare < 0) {
         STTemplate::set_message(__('You can not set check-in date in the past', ST_TEXTDOMAIN), 'danger');
         $form_validate = FALSE;
         return false;
     }
     if ($period < $booking_period) {
         STTemplate::set_message(sprintf(__('This rental allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
         $form_validate = FALSE;
         return false;
     }
     $adult_number = intval(STInput::request('adult_number', ''));
     $child_number = intval(STInput::request('child_number', ''));
     $max_adult = intval(get_post_meta($item_id, 'rental_max_adult', true));
     $max_children = intval(get_post_meta($item_id, 'rental_max_children', true));
     if ($adult_number > $max_adult) {
         STTemplate::set_message(sprintf(__('A maximum number of adult(s): %d', ST_TEXTDOMAIN), $max_adult), 'danger');
         $form_validate = FALSE;
         return false;
     }
     if ($child_number > $max_children) {
         STTemplate::set_message(sprintf(__('A maximum number of children: %d', ST_TEXTDOMAIN), $max_children), 'danger');
         $form_validate = FALSE;
         return false;
     }
     $number_room = intval(get_post_meta($item_id, 'rental_number', true));
     $check_in_tmp = date('Y-m-d', strtotime($check_in));
     $check_out_tmp = date('Y-m-d', strtotime($check_out));
     if (!RentalHelper::check_day_cant_order($item_id, $check_in_tmp, $check_out_tmp, 1)) {
         STTemplate::set_message(sprintf(__('This rental is not available from %s to %s.', ST_TEXTDOMAIN), $check_in_tmp, $check_out_tmp), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     if (!RentalHelper::_check_room_available($item_id, $check_in_tmp, $check_out_tmp, 1)) {
         STTemplate::set_message(__('This rental is not available.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $item_price = STPrice::getRentalPriceOnlyCustomPrice($item_id, strtotime($check_in), strtotime($check_out));
     $extras = STInput::request('extra_price', array());
     $numberday = TravelHelper::dateDiff($check_in, $check_out);
     $extra_price = STPrice::getExtraPrice($extras, 1, $numberday);
     $price_sale = STPrice::getSalePrice($item_id, $item_price, strtotime($check_in), strtotime($check_out));
     $discount_rate = STPrice::get_discount_rate($item_id, strtotime($check_in));
     $data = array('item_price' => $item_price, 'ori_price' => $price_sale + $extra_price, 'check_in' => $check_in, 'check_out' => $check_out, 'adult_number' => $adult_number, 'child_number' => $child_number, 'extras' => $extras, 'extra_price' => $extra_price, 'commission' => TravelHelper::get_commission(), 'discount_rate' => $discount_rate);
     if ($form_validate) {
         $form_validate = apply_filters('st_rental_add_cart_validate', $form_validate);
     }
     if ($form_validate) {
         STCart::add_cart($item_id, 1, $item_price, $data);
     }
     return $form_validate;
 }
Exemplo n.º 16
0
 function do_add_to_cart()
 {
     $pass_validate = true;
     $item_id = STInput::request('item_id');
     $number = STInput::request('number');
     $discount = STInput::request('discount');
     $price = STInput::request('price');
     if (!empty($discount)) {
         $price_sale = $price - $price * ($discount / 100);
         $data = array('discount' => $discount, 'price_sale' => $price_sale);
     }
     $data['check_in'] = STInput::request('check_in');
     $data['check_out'] = STInput::request('check_out');
     $data['type_tour'] = STInput::request('type_tour');
     $data['type_price'] = STInput::request('type_price');
     if ($data['type_price'] == 'people_price') {
         $prices = self::get_price_person($item_id);
         $data['adult_price'] = $prices['adult'];
         $data['child_price'] = $prices['child'];
         $data['discount'] = $prices['discount'];
         $data['adult_number'] = STInput::request('adult_number', 1);
         $data['child_number'] = STInput::request('children_number', 0);
     }
     $data['duration'] = STInput::request('duration');
     $type_tour = STInput::request('type_tour');
     $today = strtotime(date('m/d/Y', time()));
     if ($type_tour == 'daily_tour') {
         $check_in = strtotime(TravelHelper::convertDateFormat(STInput::request('check_in')));
     } else {
         $check_in = strtotime(get_post_meta($item_id, 'check_in', true));
     }
     $booking_period = intval(get_post_meta($item_id, 'tours_booking_period', true));
     $period = STDate::date_diff($today, $check_in);
     $expired = $check_in - $today;
     if ($type_tour == 'daily_tour') {
         if ($booking_period && $period < $booking_period) {
             STTemplate::set_message(sprintf(__('Booking is only accepted %d day(s) before today.', ST_TEXTDOMAIN), $booking_period), 'danger');
             return;
         }
     } else {
         if ($expired < 0) {
             STTemplate::set_message(__('This tour has expired', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return;
         }
     }
     if ($pass_validate) {
         $pass_validate = apply_filters('st_tour_add_cart_validate', $pass_validate, $data);
     }
     if ($pass_validate) {
         STCart::add_cart($item_id, $number, $price, $data);
     }
     return $pass_validate;
 }
Exemplo n.º 17
0
 static function get_coupon_value($coupon, $total = false, $cart_items = array(), $customer_email = false, $check_in = null)
 {
     if (!$total) {
         $total = STCart::get_total_with_out_tax();
     }
     if (empty($cart_items)) {
         $cart_items = STCart::get_items();
     }
     $coupon_object = get_page_by_title($coupon, OBJECT, 'st_coupon_code');
     if (!$coupon_object) {
         return array('status' => 0, 'message' => __('Coupon Not Found', ST_TEXTDOMAIN));
     }
     $discount_value = 0;
     $coupon_post_id = $coupon_object->ID;
     $discount_type = get_post_meta($coupon_post_id, 'discount_type', true);
     //$booking_type_available = get_post_meta($coupon_post_id,'booking_type_available',true);
     $amount = get_post_meta($coupon_post_id, 'amount', true);
     $expiry_date = get_post_meta($coupon_post_id, 'expiry_date', true);
     $minimum_spend = get_post_meta($coupon_post_id, 'minimum_spend', true);
     $maximum_spend = get_post_meta($coupon_post_id, 'maximum_spend', true);
     $required_porduct = get_post_meta($coupon_post_id, 'include_products', true);
     $exclude_products = get_post_meta($coupon_post_id, 'exclude_products', true);
     $limit_per_coupon = get_post_meta($coupon_post_id, 'limit_per_coupon', true);
     $limit_per_user = get_post_meta($coupon_post_id, 'limit_per_user', true);
     //Validate Expiry Date
     if ($expiry_date) {
         $datediff = STDate::date_diff2($expiry_date, date('Y-m-d'));
         if ($datediff <= 1) {
             return array('status' => 0, 'message' => __('This coupon is expired', ST_TEXTDOMAIN));
         }
     }
     //Validate Minium Spend
     if ($minimum_spend) {
         if ($minimum_spend > $total) {
             return array('status' => 0, 'message' => sprintf(__('This coupon is only applicable for bills spent over %s', ST_TEXTDOMAIN), TravelHelper::format_money($minimum_spend)));
         }
     }
     //Validate Maximum Spend
     if ($maximum_spend) {
         if ($maximum_spend < $total) {
             return array('status' => 0, 'message' => sprintf(__('This coupon is only applicable for bills spent less than %s', ST_TEXTDOMAIN), TravelHelper::format_money($maximum_spend)));
         }
     }
     //Validate Required Product
     if ($required_porduct) {
         $ids = explode(',', $required_porduct);
         $products_name = array();
         $check = array();
         foreach ($ids as $key) {
             if (self::_check_in_items($key, $cart_items)) {
                 $check[] = 1;
             }
             $products_name[] = "<a class='dotted_bottom' href='" . get_permalink($key) . "' target='_blank'>" . get_the_title($key) . "</a>";
         }
         if (empty($check)) {
             return array('status' => 0, 'message' => sprintf(__('This coupon is required %s in the cart', ST_TEXTDOMAIN), implode(', ', $products_name)));
         }
     }
     //Validate Exclude Product
     if ($exclude_products) {
         $ids = explode(',', $exclude_products);
         $products_name = array();
         $check = array();
         foreach ($ids as $key) {
             if (self::_check_in_items($key, $cart_items)) {
                 $check[] = 1;
             }
             $products_name[] = "<a class='dotted_bottom' href='" . get_permalink($key) . "' target='_blank'>" . get_the_title($key) . "</a>";
         }
         if (!empty($check)) {
             return array('status' => 0, 'message' => sprintf(__('This coupon is required %s NOT in the cart', ST_TEXTDOMAIN), implode(', ', $products_name)));
         }
     }
     //Validate Used Time
     $coupon_code = $coupon_object->post_title;
     if ($limit_per_coupon) {
         global $wpdb;
         $query = "\r\n                    SELECT  count({$wpdb->prefix}posts.ID) as total\r\n                    FROM    {$wpdb->prefix}posts\r\n                    join {$wpdb->prefix}postmeta on {$wpdb->prefix}postmeta.post_id = {$wpdb->prefix}posts.ID and {$wpdb->prefix}postmeta.meta_key = 'coupon_code' \r\n                    and {$wpdb->prefix}postmeta.meta_value = '{$coupon_code}'\r\n                    WHERE  post_type = 'st_order'";
         $result = $wpdb->get_results($query);
         $count_used = 0;
         if (!empty($result) and is_array($result)) {
             foreach ($result as $key => $value) {
                 $count_used += $value->total;
             }
         }
         if ($count_used >= $limit_per_coupon) {
             return array('status' => 0, 'message' => __('This coupon is reach the limit of usage', ST_TEXTDOMAIN));
         }
     }
     // Validate Per User
     if ($limit_per_user and is_user_logged_in()) {
         /*$q_arg=array(
                             'post_type'=>'st_order'
                         );
         
                         if(is_user_logged_in()){
                             $q_arg['meta_key']='id_user';
                             $q_arg['meta_value']=get_current_user_id();
                         }elseif($customer_email){
                             $q_arg['meta_key']='st_email';
                             $q_arg['meta_value']=$customer_email;
                         }*/
         $q_arg = array('post_type' => 'st_order', 'meta_query' => array('relation' => 'AND', array('key' => 'coupon_code', 'value' => $coupon_code, 'type' => 'CHAR', 'compare' => '='), array('key' => 'id_user', 'value' => get_current_user_id(), 'compare' => '=')));
         $query = new WP_Query($q_arg);
         if ($query->found_posts >= $limit_per_user) {
             return array('status' => 0, 'message' => __('This coupon is reach the limit of usage per user', ST_TEXTDOMAIN));
         }
     }
     if ($amount) {
         switch ($discount_type) {
             case "cart_percent":
                 if ($amount < 100) {
                     $discount_value = $total / 100 * $amount;
                 } else {
                     $discount_value = $total;
                 }
                 break;
                 // Currently, Only one product in cart, so dont need to use bellow discount type
                 //                case "product_amount":
                 //                    $discount_value=self::_get_product_discount($amount,explode(',',$required_porduct),$cart_items,'amount');
                 //                    break;
                 //                case "product_percent":
                 //                    $discount_value=self::_get_product_discount($amount,explode(',',$required_porduct),$cart_items,'percent');
                 //                    break;
                 // Default: Card Discount
             // Currently, Only one product in cart, so dont need to use bellow discount type
             //                case "product_amount":
             //                    $discount_value=self::_get_product_discount($amount,explode(',',$required_porduct),$cart_items,'amount');
             //                    break;
             //                case "product_percent":
             //                    $discount_value=self::_get_product_discount($amount,explode(',',$required_porduct),$cart_items,'percent');
             //                    break;
             // Default: Card Discount
             default:
                 $discount_value = $amount > $total ? $total : $amount;
                 break;
         }
     }
     $result = apply_filters('st_get_coupon_value', array('status' => 1, 'value' => $discount_value, 'coupon' => $coupon, 'total' => $total, 'cart_items' => $cart_items));
     return array('status' => $result['status'], 'value' => isset($result['value']) ? $result['value'] : 0, 'message' => isset($result['message']) ? $result['message'] : 0, 'data' => isset($result['data']) ? $result['data'] : 0);
 }
Exemplo n.º 18
0
 function _save_booking($order_id)
 {
     if (!check_admin_referer('shb_action', 'shb_field')) {
         die;
     }
     //Update Order
     $orderitem = array('item_number' => '', 'item_id' => '', 'item_price' => '', 'check_in' => '', 'check_in_time' => '', 'check_out' => '', 'check_out_time' => '', 'item_equipment' => '', 'pick_up' => '', 'drop_off' => '', 'driver_age' => '', 'driver_name' => '');
     $data = wp_parse_args($_POST, $orderitem);
     foreach ($orderitem as $val) {
         if ($val == 'check_in' or $val == 'check_out') {
             update_post_meta($order_id, $val, date('Y-m-d', strtotime($data[$val])));
         } else {
             if ($val == 'item_equipment') {
                 $items = $data[$val];
                 $list_items = array();
                 if (!empty($items)) {
                     foreach ($items as $k => $v) {
                         $tmp = explode("|", $v);
                         $list_items[$tmp[1]] = $tmp[0];
                     }
                 }
                 update_post_meta($order_id, $val, json_encode($list_items));
             } else {
                 if (isset($data[$val])) {
                     update_post_meta($order_id, $val, $data[$val]);
                 }
             }
         }
     }
     //Update User
     $order_parent = $order_id;
     $id_user = isset($_POST['id_user']) ? $_POST['id_user'] : FALSE;
     if ($order_parent and $id_user) {
         update_post_meta($order_parent, 'id_user', $id_user);
     }
     $check_out_field = STCart::get_checkout_fields();
     if (!empty($check_out_field)) {
         foreach ($check_out_field as $field_name => $field_desc) {
             update_post_meta($order_id, $field_name, STInput::post($field_name));
         }
     }
     $user_fields = array('status' => '', 'st_tax' => '');
     $data = wp_parse_args($_POST, $user_fields);
     if ($order_parent) {
         foreach ($user_fields as $val => $value) {
             update_post_meta($order_parent, $val, $data[$val]);
         }
     }
     STAdmin::set_message('Update Success', 'updated');
 }
Exemplo n.º 19
0
 static function _apply_coupon()
 {
     if (STInput::post('st_action') == 'apply_coupon') {
         $_SESSION['st_cart_coupon'] = array();
         $code = STInput::post('coupon_code');
         if (!$code) {
             self::$coupon_error = array('status' => 0, 'message' => __('Coupon is not correct', ST_TEXTDOMAIN));
         }
         $status = self::do_apply_coupon($code);
         if (!$status['status']) {
             self::$coupon_error = array('status' => 0, 'message' => $status['message']);
         }
     }
 }
Exemplo n.º 20
0
 /**
  * @since 1.0.9
  * @update 1.1.3
  **/
 function do_add_to_cart()
 {
     $pass_validate = true;
     $data_price_cars = json_decode(str_ireplace("\\", '', STInput::request('data_price_cars')));
     $data_price_items = json_decode(str_ireplace("\\", '', STInput::request('data_price_items')));
     $selected_equipments = json_decode(str_ireplace("\\", '', STInput::request('selected_equipments')));
     $discount = STInput::request('discount');
     $price_unit = STInput::request('price');
     $price_old = STInput::request('price_old');
     $item_id = STInput::request('item_id');
     $number = 1;
     $price_total = STInput::request('data_price_total');
     $check_in = $data_price_cars->date_time->pick_up_date . ' ' . $data_price_cars->date_time->pick_up_time;
     $check_in = date('Y-m-d H:i:s', strtotime($check_in));
     $check_out = $data_price_cars->date_time->drop_off_date . ' ' . $data_price_cars->date_time->drop_off_time;
     $check_out = date('Y-m-d H:i:s', strtotime($check_out));
     $data = array('data_price_cars' => $data_price_cars, 'data_price_items' => $data_price_items, 'discount' => $discount, 'price_old' => $price_old, 'check_in' => STInput::request('check_in'), 'check_in_timestamp' => STInput::request('check_in_timestamp'), 'check_out' => STInput::request('check_out'), 'check_out_timestamp' => STInput::request('check_out_timestamp'), 'price_total' => $price_total, 'price_unit' => self::get_price_unit(), 'selected_equipments' => $selected_equipments);
     // Validate required field
     $change_location_date_box = $this->get_search_fields_box();
     $field_types = $this->get_search_fields_name();
     if (!empty($change_location_date_box)) {
         $message = '';
         foreach ($change_location_date_box as $key => $value) {
             if (isset($field_types[$value['field_atrribute']]) and $value['is_required'] == 'on') {
                 $field_name = isset($field_types[$value['field_atrribute']]['field_name']) ? $field_types[$value['field_atrribute']]['field_name'] : false;
                 if ($field_name) {
                     if (is_array($field_name)) {
                         foreach ($field_name as $v) {
                             if (!STInput::request($v)) {
                                 $message .= sprintf(__('%s is required', ST_TEXTDOMAIN), $value['title']) . '<br>';
                                 $pass_validate = false;
                             }
                         }
                     } elseif (is_string($field_name)) {
                         if (!STInput::request($field_name)) {
                             $message .= sprintf(__('%s is required', ST_TEXTDOMAIN), $value['title']) . '<br>';
                             $pass_validate = false;
                         }
                     }
                 }
             }
         }
         if ($message) {
             $message = substr($message, 0, -4);
             STTemplate::set_message($message, 'danger');
         }
     }
     $is_required_country = st()->get_option('is_required_country', 'off');
     if ($is_required_country == 'on') {
         if (STInput::request('county_pick_up') != STInput::request('county_drop_off') or !STInput::request('county_drop_off') or !STInput::request('county_pick_up')) {
             STTemplate::set_message(__('Pick-up and Drop-off are not in the same country. Please re-check it.', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
         }
     }
     $today = strtotime(date('m/d/Y', time()));
     $check_in_unix = strtotime(TravelHelper::convertDateFormat($data_price_cars->date_time->pick_up_date));
     $booking_period = intval(get_post_meta($item_id, 'cars_booking_period', true));
     $period = STDate::date_diff($today, $check_in_unix);
     $var = $check_in_unix - $today;
     if ($var < 0) {
         STTemplate::set_message(__('You can not set check-in date in the past'), 'danger');
         $pass_validate = false;
     } else {
         if ($booking_period && $period < $booking_period) {
             STTemplate::set_message(sprintf(__('Booking is only accepted %d day(s) before today.', ST_TEXTDOMAIN), $booking_period), 'danger');
             $pass_validate = false;
         }
     }
     if (!$this->_is_slot_available($item_id, $check_in, $check_out)) {
         STTemplate::set_message(__('Sorry! This Car is not available.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = false;
     }
     //if($pickup)
     // Allow to be filtered
     $pass_validate = apply_filters('st_car_add_cart_validate', $pass_validate, $item_id, $number, $price_unit, $data);
     if ($pass_validate) {
         STCart::add_cart($item_id, $number, $price_unit, $data);
     }
     return $pass_validate;
 }
Exemplo n.º 21
0
 function do_add_to_cart()
 {
     $pass_validate = true;
     $item_id = STInput::request('item_id', '');
     if ($item_id <= 0 || get_post_type($item_id) != 'st_holidays') {
         STTemplate::set_message(__('This holiday is not available..', ST_TEXTDOMAIN), 'danger');
         $pass_validate = false;
         return false;
     }
     $number = 1;
     $adult_number = intval(STInput::request('adult_number', 1));
     $child_number = intval(STInput::request('child_number', 0));
     $infant_number = intval(STInput::request('infant_number', 0));
     $data['adult_number'] = $adult_number;
     $data['child_number'] = $child_number;
     $data['infant_number'] = $infant_number;
     $max_number = intval(get_post_meta($item_id, 'max_people', true));
     $type_holiday = get_post_meta($item_id, 'type_holiday', true);
     $data['type_holiday'] = $type_holiday;
     $today = date('Y-m-d');
     $check_in = STInput::request('check_in', '');
     $check_out = STInput::request('check_out', '');
     if (!$check_in || !$check_out) {
         STTemplate::set_message(__('Select a holiday in the calendar above.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $compare = TravelHelper::dateCompare($today, $check_in);
     if ($compare < 0) {
         STTemplate::set_message(__('This holiday has expired', ST_TEXTDOMAIN), 'danger');
         $pass_validate = false;
         return false;
     }
     $booking_period = intval(get_post_meta($item_id, 'holidays_booking_period', true));
     $period = TravelHelper::dateDiff($today, $check_in);
     if ($period < $booking_period) {
         STTemplate::set_message(sprintf(__('This holiday allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
         $pass_validate = false;
         return false;
     }
     if ($adult_number + $child_number + $infant_number > $max_number) {
         STTemplate::set_message(sprintf(__('Max of people for this holiday is %d people', ST_TEXTDOMAIN), $max_number), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $holiday_available = HolidayHelper::checkAvailableHoliday($item_id, strtotime($check_in), strtotime($check_out));
     if (!$holiday_available) {
         STTemplate::set_message(__('The check in, check out day is not invalid or this holiday not available.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $free_people = intval(get_post_meta($item_id, 'max_people', true));
     $result = HolidayHelper::_get_free_peple($item_id, strtotime($check_in), strtotime($check_out));
     if (is_array($result) && count($result)) {
         $free_people = intval($result['free_people']);
     }
     if ($free_people < $adult_number + $child_number + $infant_number) {
         STTemplate::set_message(sprintf(__('This holiday only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $data_price = STPrice::getPriceByPeopleHoliday($item_id, strtotime($check_in), strtotime($check_out), $adult_number, $child_number, $infant_number);
     $total_price = $data_price['total_price'];
     $sale_price = STPrice::getSaleHolidaySalePrice($item_id, $total_price, $type_holiday, strtotime($check_in));
     $data['check_in'] = date('m/d/Y', strtotime($check_in));
     $data['check_out'] = date('m/d/Y', strtotime($check_out));
     $people_price = STPrice::getPeoplePrice($item_id, strtotime($check_in), strtotime($check_out));
     $data = wp_parse_args($data, $people_price);
     $data['ori_price'] = $sale_price;
     $data['currency'] = TravelHelper::get_current_currency('symbol');
     $data['currency_rate'] = TravelHelper::get_current_currency('rate');
     $data['currency_pos'] = TravelHelper::get_current_currency('booking_currency_pos');
     $data['commission'] = TravelHelper::get_commission();
     $data['data_price'] = $data_price;
     $data['discount_rate'] = STPrice::get_discount_rate($item_id, strtotime($check_in));
     if ($pass_validate) {
         $data['duration'] = $type_holiday == 'daily_holiday' ? floatval(get_post_meta($item_id, 'duration_day', true)) : '';
         if ($pass_validate) {
             STCart::add_cart($item_id, $number, $sale_price, $data);
         }
     }
     return $pass_validate;
 }
Exemplo n.º 22
0
        </tr>
        <?php 
if (STCart::use_coupon()) {
    $price_coupon = floatval(STCart::get_coupon_amount());
    if ($price_coupon < 0) {
        $price_coupon = 0;
    }
    ?>
            <tr>
                <td class="text-left title">
                    <?php 
    printf(st_get_language('coupon_key'), STCart::get_coupon_code());
    ?>
 <br/>
                    <a href="<?php 
    echo st_get_link_with_search(get_permalink(), array('remove_coupon'), array('remove_coupon' => STCart::get_coupon_code()));
    ?>
"
                       class="danger"><small class='text-color'>(<?php 
    st_the_language('Remove coupon');
    ?>
 )</small></a>
                </td>
                <td class="text-right ">
                    <strong>
                    - <?php 
    echo TravelHelper::format_money($price_coupon);
    ?>
                    </strong>
                </td>
            </tr>
Exemplo n.º 23
0
</label>
                                    <div class="controls">
                                        <input type="text" name="st_tax" value="<?php 
echo get_post_meta($item_id, 'st_tax', true);
?>
" class="form-control ">%
                                    </div>
                                </div>
                                <div class="form-row">
                                    <label class="form-label" for=""><?php 
_e('Total', ST_TEXTDOMAIN);
?>
</label>
                                    <div class="controls">
                                        <input type="text" disabled value="<?php 
echo number_format((double) STCart::get_order_item_total($item_id, get_post_meta($item_id, 'st_tax', true)));
?>
" class="form-control "><?php 
_e('Auto calculate', ST_TEXTDOMAIN);
?>
                                    </div>
                                </div>
                                <div class="form-row">
                                    <label class="form-label" for="check_in"><?php 
_e('Check in', ST_TEXTDOMAIN);
?>
</label>
                                    <div class="controls">
                                        <input placeholder="dd/mm/yyyy" type="text" name="check_in" value="<?php 
$time = get_post_meta($item_id, 'check_in', true);
if ($time) {
Exemplo n.º 24
0
 function do_checkout($order_id)
 {
     update_post_meta($order_id, 'status', 'incomplete');
     $paypal = new STPaypal();
     $pp = $paypal->get_authorize_url($order_id);
     if (isset($pp['redirect_url']) and $pp['redirect_url']) {
         $pp_link = $pp['redirect_url'];
     }
     do_action('st_before_redirect_paypal');
     if (!isset($pp_link)) {
         return array('status' => false, 'message' => isset($pp['message']) ? $pp['message'] : false, 'data' => isset($pp['data']) ? $pp['data'] : false);
     }
     //Destroy cart on success
     STCart::destroy_cart();
     if (!$pp_link) {
         return array('status' => false, 'message' => __('Can not get Paypal Authorize URL.', ST_TEXTDOMAIN));
     } else {
         return array('status' => true, 'redirect' => $pp_link);
     }
 }
 function _save_booking($order_id)
 {
     if (!check_admin_referer('shb_action', 'shb_field')) {
         die('shb_action');
     }
     //Update Order
     $orderitem = array('item_number', 'item_id', 'item_price', 'check_in', 'check_out');
     $data = wp_parse_args($_POST, $orderitem);
     foreach ($orderitem as $val) {
         if ($val == 'check_in' or $val == 'check_out') {
             update_post_meta($order_id, $val, date('Y-m-d', strtotime($data[$val])));
         } else {
             update_post_meta($order_id, $val, $data[$val]);
         }
     }
     //Update User
     $order_parent = $order_id;
     $id_user = isset($_POST['id_user']) ? $_POST['id_user'] : false;
     if ($order_parent and $id_user) {
         update_post_meta($order_parent, 'id_user', $id_user);
     }
     $check_out_field = STCart::get_checkout_fields();
     if (!empty($check_out_field)) {
         foreach ($check_out_field as $field_name => $field_desc) {
             update_post_meta($order_id, $field_name, STInput::post($field_name));
         }
     }
     $user_fields = array('status' => '', 'st_tax' => '');
     $data = wp_parse_args($_POST, $user_fields);
     if ($order_parent) {
         foreach ($user_fields as $val => $value) {
             update_post_meta($order_parent, $val, $data[$val]);
         }
     }
     STAdmin::set_message('Update Success', 'updated');
 }
Exemplo n.º 26
0
 function check_completePurchase($order_id = false)
 {
     //Check cart is not empty
     if ($order_id and false !== get_post_status($order_id)) {
         $total = get_post_meta($order_id, 'total_price', true);
         $gateway = Omnipay::create('PayPal_Express');
         $gateway->setUsername($this->apiUserName);
         $gateway->setPassword($this->apiPass);
         $gateway->setSignature($this->apiSignature);
         $gateway->setTestMode(true);
         $amount = TravelHelper::convert_money($total);
         $order_token_code = get_post_meta($order_id, 'order_token_code', true);
         if (!$order_token_code) {
             $array = array('gateway_name' => 'st_paypal', 'order_code' => $order_id, 'status' => 'success');
             $array_error = array('gateway_name' => 'st_paypal', 'order_code' => $order_id, 'status' => 'error');
         } else {
             $array = array('gateway_name' => 'st_paypal', 'order_token_code' => $order_token_code, 'status' => 'success');
             $array_error = array('gateway_name' => 'st_paypal', 'order_token_code' => $order_token_code, 'status' => 'error');
         }
         $response = $gateway->completePurchase(array('amount' => (double) $amount, 'currency' => TravelHelper::get_current_currency('name'), 'description' => __('Traveler Booking', ST_TEXTDOMAIN), 'returnUrl' => add_query_arg($array, STCart::get_success_link()), 'cancelUrl' => add_query_arg($array_error, STCart::get_success_link())))->send();
         if ($response->isSuccessful()) {
             $data = $response->getData();
             $data2 = $gateway->fetchCheckout(array('transactionReference' => $data['TOKEN']))->send();
             $transaction_data = $data2->getData();
             //Try to create user and create new orders with paypal transaction detail
             return STGatewayPaypal::paypal_checkout($transaction_data, $order_id);
             //return true;
         } elseif ($response->isRedirect()) {
             //$response->redirect(); // this will automatically forward the customer
             return array('status' => false, 'redirect_url' => $response->getRedirectUrl(), 'func' => 'check_completePurchase');
             //                    return ;
         } else {
             // not successful
             return array('status' => false, 'message' => $response->getMessage());
         }
     } else {
         // not successful
         return array('status' => false, 'message' => __('Order Code is not exists', ST_TEXTDOMAIN));
     }
 }
Exemplo n.º 27
0
 function _save_booking($order_id)
 {
     if (!check_admin_referer('shb_action', 'shb_field')) {
         die;
     }
     $data = $this->_check_validate();
     if (is_array($data)) {
         $check_out_field = STCart::get_checkout_fields();
         if (!empty($check_out_field)) {
             foreach ($check_out_field as $field_name => $field_desc) {
                 update_post_meta($order_id, $field_name, STInput::post($field_name));
             }
         }
         $item_data = array('status' => $_POST['status']);
         foreach ($item_data as $val => $value) {
             update_post_meta($order_id, $val, $value);
         }
         if (TravelHelper::checkTableDuplicate('st_rental')) {
             global $wpdb;
             $table = $wpdb->prefix . 'st_order_item_meta';
             $where = array('order_item_id' => $order_id);
             $data = array('status' => $_POST['status']);
             $wpdb->update($table, $data, $where);
         }
         STCart::send_mail_after_booking($order_id, true);
         STCart::send_email_confirm($order_id);
         wp_safe_redirect(self::$booking_page);
     }
 }
Exemplo n.º 28
0
 function do_add_to_cart()
 {
     $pass_validate = true;
     $item_id = intval(STInput::request('item_id', ''));
     if ($item_id <= 0 || get_post_type($item_id) != 'st_activity') {
         STTemplate::set_message(__('This activity is not available..', ST_TEXTDOMAIN), 'danger');
         $pass_validate = false;
         return false;
     }
     $number = 1;
     $type_activity = STInput::request('type_activity', 'specific_date');
     $adult_number = intval(STInput::request('adult_number', 1));
     $child_number = intval(STInput::request('child_number', 0));
     $infant_number = intval(STInput::request('infant_number', 0));
     $max_number = intval(get_post_meta($item_id, 'max_people', true));
     $today = date('Y-m-d');
     if ($adult_number + $child_number + $infant_number > $max_number) {
         STTemplate::set_message(sprintf(__('Max of people for this activity is %d people', ST_TEXTDOMAIN), $max_number), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     if ($type_activity == 'specific_date') {
         $check_in = TravelHelper::convertDateFormat(STInput::request('check_in', ''));
         $check_out = TravelHelper::convertDateFormat(STInput::request('check_out', ''));
         if (empty($check_in)) {
             STTemplate::set_message(__('The check in field is not empty.', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         if (empty($check_out)) {
             STTemplate::set_message(__('The check out field is not empty.', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         $compare = TravelHelper::dateCompare($today, $check_in);
         if ($compare < 0) {
             STTemplate::set_message(__('This activity has expired', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         $people = $adult_number + $child_number + $child_number;
         $result = ActivityHelper::_get_free_peple_special($item_id, $check_in, $check_out);
         $free_people = intval(get_post_meta($item_id, 'max_people', true));
         if (is_array($result) && count($result)) {
             $free_people = intval($result['free_people']);
         }
         if ($free_people < $people) {
             STTemplate::set_message(sprintf(__('This activity only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
             $pass_validate = false;
             return false;
         }
         $data['check_in'] = date('m/d/Y', strtotime($check_in));
         $data['check_out'] = date('m/d/Y', strtotime($check_out));
     } elseif ($type_activity == 'daily_activity') {
         $check_in = STInput::request('check_in', '');
         if (empty($check_in)) {
             STTemplate::set_message(__('The check in field is not empty.', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         $check_in = TravelHelper::convertDateFormat($check_in);
         $check_in = date('Y-m-d', strtotime($check_in));
         $duration = intval(get_post_meta($item_id, 'duration', true));
         $check_out = $duration >= 2 ? strtotime('+ ' . $duration . ' days', strtotime($check_in)) : strtotime('+ ' . $duration . ' day', strtotime($check_in));
         $check_out = date('Y-m-d', $check_out);
         $booking_period = intval(get_post_meta($item_id, 'activity_booking_period', true));
         $period = TravelHelper::dateDiff($today, $check_in);
         $compare = TravelHelper::dateCompare($today, $check_in);
         if ($compare < 0) {
             STTemplate::set_message(__('You can not set check-in date in the past', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         if ($booking_period && $booking_period > $period) {
             STTemplate::set_message(sprintf(__('This activity allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
             $pass_validate = false;
             return false;
         }
         $people = $adult_number + $child_number + $child_number;
         $result = ActivityHelper::_get_free_peple_daily($item_id, $check_in);
         $free_people = intval(get_post_meta($item_id, 'max_people', true));
         if (is_array($result) && count($result)) {
             $free_people = intval($result['free_people']);
         }
         if ($free_people < $people) {
             STTemplate::set_message(sprintf(__('This activity only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
             $pass_validate = false;
             return false;
         }
         $data['duration'] = $duration;
     }
     $data['adult_number'] = $adult_number;
     $data['child_number'] = $child_number;
     $data['infant_number'] = $infant_number;
     $data['check_in'] = date('m/d/Y', strtotime($check_in));
     $data['check_out'] = date('m/d/Y', strtotime($check_out));
     $data['type_activity'] = $type_activity;
     $data_price = STPrice::getPriceByPeople($item_id, strtotime($check_in), strtotime($check_out), $adult_number, $child_number, $infant_number);
     $total_price = $data_price['total_price'];
     $sale_price = STPrice::getSaleTourSalePrice($item_id, $total_price, $type_activity, strtotime($check_in));
     $discount_rate = STPrice::get_discount_rate($item_id, strtotime($check_in));
     $data['adult_price'] = floatval(get_post_meta($item_id, 'adult_price', true));
     $data['child_price'] = floatval(get_post_meta($item_id, 'child_price', true));
     $data['infant_price'] = floatval(get_post_meta($item_id, 'infant_price', true));
     $data['ori_price'] = $sale_price;
     $data['currency'] = TravelHelper::get_current_currency('symbol');
     $data['currency_rate'] = TravelHelper::get_current_currency('rate');
     $data['currency_pos'] = TravelHelper::get_current_currency('booking_currency_pos');
     $data['commission'] = TravelHelper::get_commission();
     $data['data_price'] = $data_price;
     $data['discount_rate'] = $discount_rate;
     if ($pass_validate) {
         $pass_validate = apply_filters('st_activity_add_cart_validate', $pass_validate);
     }
     if ($pass_validate) {
         STCart::add_cart($item_id, $number, $sale_price, $data);
     }
     return $pass_validate;
 }
Exemplo n.º 29
0
 /**
  * @since 1.0.9
  * @update 1.1.3
  **/
 function do_add_to_cart()
 {
     $pass_validate = true;
     $item_id = STInput::request('item_id', '');
     if ($item_id <= 0 || get_post_type($item_id) != 'st_cars') {
         STTemplate::set_message(__('This car is not available.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $number = 1;
     // Validate required field
     if (!isset($_POST['booking_by']) || $_POST['booking_by'] != 'partner') {
         $change_location_date_box = $this->get_search_fields_box();
         $field_types = $this->get_search_fields_name();
         if (!empty($change_location_date_box)) {
             $message = '';
             foreach ($change_location_date_box as $key => $value) {
                 if (isset($field_types[$value['field_atrribute']]) and $value['is_required'] == 'on') {
                     $field_name = isset($field_types[$value['field_atrribute']]['field_name']) ? $field_types[$value['field_atrribute']]['field_name'] : false;
                     if ($field_name) {
                         if (is_array($field_name)) {
                             foreach ($field_name as $v) {
                                 if (!STInput::request($v)) {
                                     $message .= sprintf(__('%s is required', ST_TEXTDOMAIN), $value['title']) . '<br>';
                                     $pass_validate = false;
                                 }
                             }
                         } elseif (is_string($field_name)) {
                             if (!STInput::request($field_name)) {
                                 $message .= sprintf(__('%s is required', ST_TEXTDOMAIN), $value['title']) . '<br>';
                                 $pass_validate = false;
                             }
                         }
                     }
                 }
             }
             if ($message) {
                 $message = substr($message, 0, -4);
                 STTemplate::set_message($message, 'danger');
             }
         }
     }
     $check_in = '';
     $check_in_n = '';
     $check_in_time = '';
     if (isset($_REQUEST['pick-up-date']) && !empty($_REQUEST['pick-up-date'])) {
         $check_in = TravelHelper::convertDateFormat($_REQUEST['pick-up-date']);
         $check_in_n = $check_in;
     }
     if (isset($_REQUEST['pick-up-time']) && !empty($_REQUEST['pick-up-time'])) {
         $check_in .= ' ' . $_REQUEST['pick-up-time'];
         $check_in_time = $_REQUEST['pick-up-time'];
     }
     $check_in = date('Y-m-d H:i:s', strtotime($check_in));
     $check_out = '';
     $check_out_n = '';
     $check_out_time = '';
     if (isset($_REQUEST['drop-off-date']) && !empty($_REQUEST['drop-off-date'])) {
         $check_out = TravelHelper::convertDateFormat($_REQUEST['drop-off-date']);
         $check_out_n = $check_out;
     }
     if (isset($_REQUEST['drop-off-time']) && !empty($_REQUEST['drop-off-time'])) {
         $check_out .= ' ' . $_REQUEST['drop-off-time'];
         $check_out_time = $_REQUEST['drop-off-time'];
     }
     $check_out = date('Y-m-d H:i:s', strtotime($check_out));
     $location_id_pick_up = STInput::request('location_id_pick_up', '');
     $location_id_drop_off = STInput::request('location_id_drop_off', '');
     if (isset($_REQUEST['location_id_pick_up']) && !empty($_REQUEST['location_id_pick_up']) && isset($_REQUEST['location_id_drop_off']) && !empty($_REQUEST['location_id_drop_off'])) {
         $location_id_pick_up = intval(STInput::request('location_id_pick_up', '0'));
         $location_id_drop_off = intval(STInput::request('location_id_drop_off', '0'));
         $pickup_country = get_post_meta($location_id_pick_up, 'location_country', true);
         $dropoff_country = get_post_meta($location_id_drop_off, 'location_country', true);
         if (!$pickup_country) {
             STTemplate::set_message(__('The \'country\' field not set for the \'' . get_the_title($location_id_pick_up) . '\'', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         if (!$dropoff_country) {
             STTemplate::set_message(__('The \'country\' field not set for \'' . get_the_title($location_id_drop_off) . '\'', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         if ($pickup_country != $dropoff_country) {
             STTemplate::set_message(__('The country is not same', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
     }
     $today = date('m/d/Y');
     $booking_period = intval(get_post_meta($item_id, 'cars_booking_period', true));
     $booking_min_day = intval(get_post_meta($item_id, 'cars_booking_min_day', true));
     $booking_min_hour = intval(get_post_meta($item_id, 'cars_booking_min_hour', true));
     if (empty($booking_period) || $booking_period <= 0) {
         $booking_period = 0;
     }
     $check_in_timestamp = '';
     $check_out_timestamp = '';
     if (!empty($check_in_n) && !empty($check_out_n)) {
         $period = TravelHelper::dateDiff($today, $check_in_n);
         $compare = TravelHelper::dateCompare($today, $check_in_n);
         $check_in_timestamp = strtotime($check_in);
         $check_out_timestamp = strtotime($check_out);
         if ($check_in_timestamp - $check_out_timestamp >= 0) {
             STTemplate::set_message(__('The drop off datetime is later than the pick up datetime.', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         if ($compare < 0) {
             STTemplate::set_message(__('You can not set check-in date in the past', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         if ($period < $booking_period) {
             STTemplate::set_message(sprintf(__('This car allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
             $pass_validate = false;
             return false;
         }
         $unit = st()->get_option('cars_price_unit', 'day');
         if ($unit == 'day' and $booking_min_day and $booking_min_day > self::get_date_diff($check_in_timestamp, $check_out_timestamp)) {
             STTemplate::set_message(sprintf(__('Please booking at least %d day(s)', ST_TEXTDOMAIN), $booking_min_day), 'danger');
             $pass_validate = false;
             return false;
         }
         if ($unit == 'hour' and $booking_min_hour and $booking_min_hour > self::get_date_diff($check_in_timestamp, $check_out_timestamp)) {
             STTemplate::set_message(sprintf(__('Please booking at least %d hour(s)', ST_TEXTDOMAIN), $booking_min_hour), 'danger');
             $pass_validate = false;
             return false;
         }
     }
     if ($check_in_timestamp > 0 && $check_out_timestamp > 0) {
         if (!CarHelper::_get_car_cant_order_by_id($item_id, $check_in_timestamp, $check_out_timestamp)) {
             STTemplate::set_message(__('This car is full order', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
     }
     $selected_equipments = json_decode(str_ireplace("\\", '', STInput::request('selected_equipments', '')));
     $info_price = STCars::get_info_price($item_id, strtotime($check_in), strtotime($check_out));
     $price_unit = $info_price['price'];
     $item_price = floatval(get_post_meta($item_id, 'cars_price', true));
     $price_equipment = STPrice::getPriceEuipmentCar($selected_equipments, $check_in_timestamp, $check_out_timestamp);
     $sale_price = STPrice::getSaleCarPrice($item_id, $item_price, strtotime($check_in), strtotime($check_out));
     $car_sale_price = STPrice::get_car_price_by_number_of_day_or_hour($item_id, $item_price, strtotime($check_in), strtotime($check_out));
     $discount_rate = STPrice::get_discount_rate($item_id, strtotime($check_in));
     $numberday = $numberday = STCars::get_date_diff(strtotime($check_in), strtotime($check_out), st()->get_option('cars_price_unit', 'day'));
     $data = array('check_in' => $check_in_n, 'check_out' => $check_out_n, 'check_in_time' => $check_in_time, 'check_out_time' => $check_out_time, 'check_in_timestamp' => strtotime($check_in), 'check_out_timestamp' => strtotime($check_out), 'location_id_pick_up' => $location_id_pick_up, 'location_id_drop_off' => $location_id_drop_off, 'pick_up' => get_the_title($location_id_pick_up), 'drop_off' => get_the_title($location_id_drop_off), 'ori_price' => $sale_price + $price_equipment, 'item_price' => $item_price, 'sale_price' => $car_sale_price, 'numberday' => $numberday, 'price_equipment' => $price_equipment, 'data_equipment' => $selected_equipments, 'commission' => TravelHelper::get_commission(), 'discount_rate' => $discount_rate);
     $pass_validate = apply_filters('st_car_add_cart_validate', $pass_validate, $item_id, $number, $price_unit, $data);
     if ($pass_validate) {
         STCart::add_cart($item_id, $number, $price_equipment + $sale_price, $data);
     }
     return $pass_validate;
 }
Exemplo n.º 30
0
                    </td>
                    <td>
                        <?php 
st_the_language('infomation');
?>
                    </td>
                </tr>
                </thead>
                <tbody>
                <?php 
$total = 0;
$i = 0;
$key = get_post_meta($order_code, 'item_id', true);
$post_type = get_post_type($key);
$i++;
$total = STCart::get_order_item_total($order_code);
$value = array();
switch ($post_type) {
    case "st_hotel":
        echo st()->load_template('hotel/success_payment_item_row', false, array('order_id' => $order_code, 'data' => $value, 'key' => $key, 'i' => $i));
        break;
    case "st_tours":
        echo st()->load_template('tours/success_payment_item_row', false, array('order_id' => $order_code, 'data' => $value, 'key' => $key, 'i' => $i));
        break;
    case "st_cars":
        echo st()->load_template('cars/success_payment_item_row', false, array('order_id' => $order_code, 'data' => $value, 'key' => $key, 'i' => $i));
        break;
    case "st_activity":
        echo st()->load_template('activity/success_payment_item_row', false, array('order_id' => $order_code, 'data' => $value, 'key' => $key, 'i' => $i));
        break;
    case "st_rental":