Beispiel #1
0
 /**
  *
  *
  * @update 1.1.1
  * */
 function do_checkout($order_id)
 {
     update_post_meta($order_id, 'status', 'pending');
     do_action('st_booking_change_status', 'pending', $order_id, 'normal_booking');
     $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);
     STCart::send_mail_after_booking($order_id, true);
     STCart::send_email_confirm($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));
 }
Beispiel #2
0
 /**
  * Validate if order is available to show booking infomation
  *
  * @since 1.0.8
  *
  * */
 function success_page_validate()
 {
     $order_code = STInput::get('order_code');
     $order_token_code = STInput::get('order_token_code');
     if ($order_token_code) {
         $order_code = STOrder::get_order_id_by_token($order_token_code);
     }
     $status = get_post_meta($order_code, 'status', true);
     $result = true;
     if ($status == 'incomplete') {
         // try to check payment complete
         $paypal = new STPaypal();
         $r = $paypal->check_completePurchase($order_code);
         if ($r) {
             if (isset($r['status'])) {
                 if ($r['status']) {
                     $result = true;
                     update_post_meta($order_code, 'status', 'complete');
                     $status = 'complete';
                     //do_action('st_email_after_booking',$order_code);
                     //do_action('st_booking_submit_form_success',$order_code);
                     STCart::send_mail_after_booking($order_code, true);
                     STCart::send_email_confirm($order_code);
                     do_action('st_booking_change_status', 'complete', $order_code, 'normal_booking');
                 } elseif (isset($r['message']) and $r['message']) {
                     $result = false;
                     STTemplate::set_message($r['message'], 'danger');
                 }
                 if (isset($r['redirect_url']) and $r['redirect_url']) {
                     echo "<script>window.location.href='" . $r['redirect_url'] . "'</script>";
                     die;
                 }
             }
         }
     }
     if ($status == 'incomplete') {
         $result = false;
         STTemplate::set_message(__("Sorry! Your payment is incomplete.", ST_TEXTDOMAIN));
     }
     return $result;
 }
 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);
     }
 }