当前位置: 首页>>代码示例>>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;未经允许,请勿转载。