當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model_Order::validate方法代碼示例

本文整理匯總了PHP中Model_Order::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Order::validate方法的具體用法?PHP Model_Order::validate怎麽用?PHP Model_Order::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model_Order的用法示例。


在下文中一共展示了Model_Order::validate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: action_update

 /**
  * Update Order
  * 
  * @param type $id  = Order ID
  */
 public function action_update($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/order/list');
     }
     // Get order to edit
     if (!($order = \Order\Model_Order::find_one_by_id($id))) {
         \Response::redirect('admin/order/list');
     }
     \View::set_global('title', 'Edit Order');
     if (\Input::post('order_details', false) && \Input::post('customer_details', false)) {
         try {
             $fields = array('status', 'shipping_method', 'tracking_no');
             $events = array();
             foreach ($fields as $field) {
                 $config = \Config::get('details.' . $field, array());
                 if (isset($config[\Input::post($field)]) && $order->{$field}) {
                     $value = $config[\Input::post($field)];
                 } else {
                     $value = \Inflector::humanize(\Input::post($field));
                 }
                 if (isset($config[$order->{$field}])) {
                     $old_value = $config[$order->{$field}];
                 } else {
                     $old_value = \Inflector::humanize($order->{$field});
                 }
                 if ($order->{$field} != \Input::post($field)) {
                     $events[] = \Inflector::humanize($field) . ' changed. ' . $old_value . ' => ' . $value;
                 }
                 $data[$field] = \Input::post($field);
             }
             // Send to customer
             if (\Input::post('send_to_customer_payment')) {
                 //echo 'send_to_customer_payment'; exit;
             }
             if (\Input::post('send_to_customer_shipping')) {
                 //echo 'send_to_customer_shipping'; exit;
             }
             $order->set($data);
             if ($order->save() && !empty($events)) {
                 foreach ($events as $event) {
                     $order_history = Model_History::forge(array('order_id' => $order->id, 'event' => $event));
                     $order_history->save();
                 }
             }
             \Messages::success('Order successfully updated.');
             if (\Input::post('status') == 'shipped_to_customer') {
                 $this->sendNoticeShipped(\Order\Model_Order::find_one_by_id($id));
             }
             // if(\Input::post('exit')) \Response::redirect(\Uri::create('admin/order/list'));
             // \Response::redirect(\Uri::admin('current'));
         } catch (\Database_Exception $e) {
             \Messages::error('<strong>' . 'There was an error while trying to update order.' . '</strong>');
         }
         // }
         //       if(\Input::post('customer_details', false))
         // {
         $val = Model_Order::validate('update');
         if ($val->run()) {
             try {
                 $order->set(\Input::post());
                 if ($order->save()) {
                     $order_history = Model_History::forge(array('order_id' => $order->id, 'event' => 'Customer details edited.'));
                     $order_history->save();
                     // \Messages::success('Order successfully updated.');
                     if (\Input::post('exit')) {
                         \Response::redirect(\Uri::create('admin/order/list'));
                     }
                     \Response::redirect(\Uri::admin('current'));
                 }
             } catch (\Database_Exception $e) {
                 \Messages::error('<strong>' . 'There was an error while trying to update order.' . '</strong>');
             }
         } else {
             // Delete uploaded images if there is news saving error
             if (isset($this->_image_data)) {
                 foreach ($this->_image_data as $image_data) {
                     $this->delete_image($image_data['saved_as']);
                 }
             }
             if ($val->error() != array()) {
                 // show validation errors
                 \Messages::error('<strong>There was an error while trying to update member</strong>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     if (\Input::post('upload_type', false) && \Input::post('upload', false)) {
         $this->uploads($id);
     }
     if (\Input::post('order_edit', false)) {
         $post = \Input::post();
         \Messages::success('Order successfully updated.');
//.........這裏部分代碼省略.........
開發者ID:EdgeCommerce,項目名稱:edgecommerce,代碼行數:101,代碼來源:order.php


注:本文中的Model_Order::validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。