当前位置: 首页>>代码示例>>PHP>>正文


PHP OrderItem::save方法代码示例

本文整理汇总了PHP中OrderItem::save方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItem::save方法的具体用法?PHP OrderItem::save怎么用?PHP OrderItem::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrderItem的用法示例。


在下文中一共展示了OrderItem::save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Order();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Order'])) {
         $model->attributes = $_POST['Order'];
         $model->id = F::get_order_id();
         $model->user_id = Yii::app()->user->id ? Yii::app()->user->id : '0';
         if ($model->save()) {
             $cart = Yii::app()->cart;
             $mycart = $cart->contents();
             foreach ($mycart as $mc) {
                 $OrderItem = new OrderItem();
                 $OrderItem->order_id = $model->order_id;
                 $OrderItem->item_id = $mc['id'];
                 $OrderItem->title = $mc['title'];
                 $OrderItem->pic_url = serialize($mc['pic_url']);
                 $OrderItem->sn = $mc['sn'];
                 $OrderItem->num = $mc['qty'];
                 $OrderItem->save();
             }
             $cart->destroy();
             $this->redirect(array('success'));
         }
     }
     //        $this->render('create', array(
     //            'model' => $model,
     //        ));
 }
开发者ID:rainsongsky,项目名称:yincart,代码行数:34,代码来源:OrderController.php

示例2: actionCreateItemToOrder

 /**
  * Creates a new model associated with an Order.
  * If creation is successful, the browser will be redirected to the Order 'view' page.
  */
 public function actionCreateItemToOrder($order_id)
 {
     $model = new OrderItem();
     $model->order_id = $order_id;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['OrderItem'])) {
         $model->attributes = $_POST['OrderItem'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('createItemToOrder', array('model' => $model));
 }
开发者ID:ever4vr,项目名称:maestro,代码行数:18,代码来源:OrderItemController.php

示例3: addOne

 /**
  * 添加一个商品到订单商品明细表中
  * @param $goods   商品ActiveRecord 或 商品id
  * @param $number  商品数量
  * @param $orderid 订单id
  * @return OrderItem|bool
  */
 public function addOne($goods = 0, $number = 1, $orderid = null)
 {
     $orderItem = new OrderItem();
     if (is_integer($goods)) {
         $goods = Goods::findOne(['goods_id' => $goods]);
     }
     $orderItem->item_name = $goods['goods_name'];
     $orderItem->item_price = $goods['goods_price'];
     $orderItem->item_unit = $goods['goods_unit'];
     $orderItem->goods_id = $goods['goods_id'];
     $orderItem->item_number = $number;
     $orderItem->subtotal = $goods['goods_price'] * $number;
     $orderItem->order_id = $orderid;
     return $orderItem->save() ? $orderItem : false;
 }
开发者ID:xiaohongyang,项目名称:yii_shop,代码行数:22,代码来源:OrderItem.php

示例4: make

 public function make()
 {
     $this->statusId = self::STATUS_NEW;
     $this->dateCreate = date(DATE_FORMAT_DB);
     $this->secretKey = $this->generateSecretKey();
     $this->save();
     foreach ($this->products as $k => $product) {
         $model = new OrderItem();
         $model->attributes = $product;
         $model->orderId = $this->id;
         $model->save();
         $this->products[$k] = $model;
     }
     return $this;
 }
开发者ID:nurastana,项目名称:familyclinickz,代码行数:15,代码来源:Order.php

示例5: addOrderItem

 public function addOrderItem($productId, $count = 1, $orderProp = array(), $orderItemProp = array())
 {
     if (!m('social')->user()) {
         return false;
     }
     $product = null;
     //Find and get product by id
     if (dbQuery($this->productClass)->id($productId)->first($product)) {
         //If product don't have field companyId then set it manually
         if (!isset($product[$this->productCompanyField])) {
             $product[$this->productCompanyField] = 0;
         }
         $order = null;
         //If data on session not exists then create new order manually and save it in db
         if (!isset($_SESSION[$this->sessionKey][$product[$this->productCompanyField]])) {
             $order = $this->getOrderIfExists($_SESSION[$this->sessionKey][$product[$this->productCompanyField]], $orderProp);
         } else {
             $order = $this->getOrderIfExists($_SESSION[$this->sessionKey][$product[$this->productCompanyField]], $orderProp);
         }
         //If order exists add new item into OrderItem
         if (isset($order)) {
             $orderItem = null;
             $orderItemQuery = dbQuery('\\samsonos\\commerce\\OrderItem')->MaterialId($productId)->OrderId($order->id);
             //In OrderItem row not exists create item else add count
             if (!$orderItemQuery->first($orderItem)) {
                 $orderItem = new OrderItem(false);
                 $orderItem->OrderId = isset($orderItemProp['OrderId']) ? $orderItemProp['OrderId'] : $order->id;
                 $orderItem->MaterialId = isset($orderItemProp['MaterialId']) ? $orderItemProp['MaterialId'] : $productId;
             }
             //Increase quantity
             $orderItem->Quantity += $count;
             if (isset($orderProp['Quantity'])) {
                 $orderItem->Quantity = $orderProp['Quantity'];
             }
             //Get price from product
             $orderItem->Price = isset($orderItemProp['Price']) ? $orderItemProp['Price'] : $product[$this->productPriceField];
             $orderItem->save();
             return $order;
         }
     }
     return false;
 }
开发者ID:samsonos,项目名称:commerce_core,代码行数:42,代码来源:Core.php

示例6: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $Item = Item::model()->with('orderItems')->findAll(new CDbCriteria(array('condition' => "order_id='{$id}'")));
     foreach ($Item as $key1 => $items) {
         foreach ($items->orderItems as $key2 => $orderItem) {
             $ItemSku[$key1][$key2] = Sku::model()->findByAttributes(array('item_id' => $orderItem->item_id, 'props_name' => $orderItem->props_name));
         }
     }
     if (isset($_POST['Order']) && isset($_POST['Sku'])) {
         $transaction = $model->dbConnection->beginTransaction();
         try {
             $model->attributes = $_POST['Order'];
             $model->update_time = time();
             if ($model->save()) {
                 $flag = array();
                 $OrderItem = OrderItem::model()->findAllByAttributes(array('order_id' => $id));
                 foreach ($OrderItem as $key => $original) {
                     $criteria = new CDbCriteria();
                     $criteria->addCondition('item_id=:item_id');
                     //                        $criteria->addCondition('price=:price');
                     $criteria->addCondition('props_name=:props_name');
                     $criteria->params[':item_id'] = $original->item_id;
                     //                        $criteria->params[':price']=$original->price;
                     $criteria->params[':props_name'] = $original->props_name;
                     $sku = Sku::model()->find($criteria);
                     $sku->stock += $original->quantity;
                     $sku->save();
                     foreach ($_POST['Sku']['sku_id'] as $skuId) {
                         if ($sku->sku_id == $skuId) {
                             $flag[$key] = 1;
                         }
                     }
                 }
                 foreach ($OrderItem as $key => $original) {
                     if ($flag[$key] != 1) {
                         $original->delete();
                     }
                 }
                 foreach ($_POST['Sku']['item_id'] as $key => $itemId) {
                     $item = Item::model()->findByPk($itemId);
                     $sku = Sku::model()->findByPk($_POST['Sku']['sku_id'][$key]);
                     if ($sku->stock < $_POST['Item-number'][$key]) {
                         throw new Exception('Stock is not enough');
                     }
                     $criteria = new CDbCriteria();
                     $criteria->addCondition('item_id=:item_id');
                     $criteria->addCondition('price=:price');
                     $criteria->addCondition('props_name=:props_name');
                     $criteria->params[':item_id'] = $sku->item_id;
                     $criteria->params[':price'] = $sku->price;
                     $criteria->params[':props_name'] = $sku->props_name;
                     $orderItem = OrderItem::model()->find($criteria);
                     if (!isset($orderItem)) {
                         $orderItem = new OrderItem();
                         $orderItem->item_id = $itemId;
                         $orderItem->title = $item->title;
                         $orderItem->desc = $item->desc;
                         $orderItem->pic = $item->getMainPic();
                     }
                     $orderItem->props_name = $sku->props_name;
                     $orderItem->price = $sku->price;
                     $orderItem->quantity = $_POST['Item-number'][$key];
                     $sku->stock -= $_POST['Item-number'][$key];
                     if (!$sku->save()) {
                         throw new Exception('Cut down stock fail');
                     }
                     $orderItem->total_price = $orderItem->price * $orderItem->quantity;
                     $orderItem->order_id = $model->order_id;
                     if (!$orderItem->save()) {
                         throw new Exception('save order item fail');
                     }
                 }
             } else {
                 throw new Exception('save order fail');
             }
             $transaction->commit();
             $this->redirect(array('view', 'id' => $model->order_id));
         } catch (Exception $e) {
             $transaction->rollBack();
         }
     }
     $this->render('update', array('model' => $model, 'Item' => $Item, 'ItemSku' => $ItemSku));
 }
开发者ID:lhfcainiao,项目名称:basic,代码行数:89,代码来源:OrderController.php

示例7: saveOrder

 function saveOrder()
 {
     $userId = Session::get('user_id');
     if (!isset($userId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $order = new Order();
     $order->status = 'active';
     $order->user_id = Session::get('user_id');
     $order->created_at = date('Y-m-d h:i:s');
     $order->save();
     $orderId = $order->id;
     $cart = Session::get('cart');
     if (isset($cart) && count($cart) > 0) {
         foreach ($cart as $item) {
             $orderItem = new OrderItem();
             $order->item_id = $item['item_id'];
             $order->item_type = $item['item_type'];
             $order->quantity = $item['quantity'];
             $order->status = 'active';
             $orderItem->order_id = $orderId;
             $orderItem->created_at = date('Y-m-d h:i:s');
             $orderItem->save();
         }
         Session::forget('cart');
         return json_encode(array('message' => 'done'));
     } else {
         return json_encode(array('message' => 'empty'));
     }
 }
开发者ID:ashutoshpandey,项目名称:course,代码行数:30,代码来源:OrderController.php

示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Order();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (!$_POST['delivery_address'] && !Yii::app()->user->isGuest) {
         echo '<script>alert("您还没有添加收货地址!")</script>';
         echo '<script type="text/javascript">history.go(-1)</script>';
     } else {
         if (isset($_POST)) {
             $transaction = $model->dbConnection->beginTransaction();
             try {
                 $cart = Yii::app()->cart;
                 if (!Yii::app()->user->isGuest) {
                     $model->attributes = $_POST;
                     $model->user_id = Yii::app()->user->id ? Yii::app()->user->id : '0';
                     $cri = new CDbCriteria(array('condition' => 'contact_id =' . $_POST['delivery_address'] . ' AND user_id = ' . Yii::app()->user->id));
                     $address = AddressResult::model()->find($cri);
                     $model->receiver_country = $address->country;
                     $model->receiver_name = $address->contact_name;
                     $model->receiver_state = $address->state;
                     $model->receiver_city = $address->city;
                     $model->receiver_district = $address->district;
                     $model->receiver_address = $address->address;
                     $model->receiver_zip = $address->zipcode;
                     $model->receiver_mobile = $address->mobile_phone;
                     $model->receiver_phone = $address->phone;
                 } else {
                     $address = $_POST['AddressResult'];
                     $model->user_id = '0';
                     $model->receiver_name = $address['contact_name'];
                     $model->receiver_state = $address['state'];
                     $model->receiver_city = $address['city'];
                     $model->receiver_district = $address['district'];
                     $model->receiver_address = $address['address'];
                     $model->receiver_zip = $address['zipcode'];
                     $model->receiver_mobile = $address['mobile_phone'];
                     $model->receiver_phone = $address['phone'];
                     $model->payment_method_id = $_POST['payment_method_id'];
                     $model->memo = $_POST['memo'];
                 }
                 $model->create_time = time();
                 $model->order_id = F::get_order_id();
                 $model->total_fee = 0;
                 if (isset($_POST['keys'])) {
                     foreach ($_POST['keys'] as $key) {
                         $item = $cart->itemAt($key);
                         $model->total_fee += $item['quantity'] * $item['price'];
                     }
                 } else {
                     $item = Item::model()->findBypk($_POST['item_id']);
                     $model->total_fee = $item->price * $_POST['quantity'];
                 }
                 if ($model->save()) {
                     if (empty($_POST['keys'])) {
                         $item = Item::model()->findBypk($_POST['item_id']);
                         $sku = Sku::model()->findByPk($_POST['sku_id']);
                         if ($sku->stock < $_POST['quantity']) {
                             throw new Exception('stock is not enough!');
                         }
                         $OrderItem = new OrderItem();
                         //                            $OrderItem->order_id = $model->order_id;
                         //                            $OrderItem->item_id = $item->item_id;
                         //                            $OrderItem->title = $item->title;
                         //                            $OrderItem->desc = $item->desc;
                         //                            $OrderItem->pic = $item->getMainPic();
                         //                            $OrderItem->props_name = $sku->props_name;
                         //                            $OrderItem->price = $item->price;
                         //                            $OrderItem->quantity = $_POST['quantity'];
                         //                            $OrderItem->total_price = $OrderItem->quantity * $OrderItem->price;
                         if (!$OrderItem::model()->saveOrderItem($OrderItem, $model->order_id, $item, $sku->props_name, $_POST['quantity'])) {
                             throw new Exception('save order item fail');
                         }
                     } else {
                         foreach ($_POST['keys'] as $key) {
                             $item = $cart->itemAt($key);
                             $sku = Sku::model()->findByPk($item['sku']['sku_id']);
                             if ($sku->stock < $item['quantity']) {
                                 throw new Exception('stock is not enough!');
                             }
                             $sku->stock -= $item['quantity'];
                             if (!$sku->save()) {
                                 throw new Exception('cut down stock fail');
                             }
                             $OrderItem = new OrderItem();
                             $OrderItem->order_id = $model->order_id;
                             $OrderItem->item_id = $item['item_id'];
                             $OrderItem->title = $item['title'];
                             $OrderItem->desc = $item['desc'];
                             $OrderItem->pic = $item->getMainPic();
                             $OrderItem->props_name = $sku['props_name'];
                             $OrderItem->price = $item['price'];
                             $OrderItem->quantity = $item['quantity'];
                             $OrderItem->total_price = $OrderItem->quantity * $OrderItem->price;
                             if (!$OrderItem->save()) {
                                 throw new Exception('save order item fail');
//.........这里部分代码省略.........
开发者ID:lhfcainiao,项目名称:basic,代码行数:101,代码来源:OrderController.php

示例9: saveOrder

 public function saveOrder()
 {
     $user_id = Session::get('user_id');
     $cart = Session::get('cart');
     if (isset($cart)) {
         $orderId = Session::get('order_id');
         $exists = false;
         if (isset($orderId)) {
             $order = Order::find($orderId);
             if (isset($order)) {
                 $exists = true;
             }
         }
         if (!$exists) {
             $order = new Order();
             $total = 0;
             foreach ($cart as $cartItem) {
                 $discounted_price = $cartItem['discounted_price'] * $cartItem['quantity'];
                 $total += $discounted_price;
             }
             $discount_on_total = 0;
             $net_total = $total - $discount_on_total;
             $order->amount = $total;
             $order->user_id = $user_id;
             //2/7/16   userid added first it was not there
             $order->discount = 0;
             $order->discount_details = '';
             $order->net_amount = $net_total;
             $order->status = 'inactive';
             // let us complete order items first
             $order->created_at = date('Y-m-d h:i:s');
             $order->save();
             foreach ($cart as $cartItem) {
                 $orderItem = new OrderItem();
                 $orderItem->order_id = $order->id;
                 if (isset($cartItem['bookId'])) {
                     $orderItem->product_id = $cartItem['bookId'];
                 }
                 if (isset($cartItem['accessoryId'])) {
                     $orderItem->product_id = $cartItem['accessoryId'];
                 }
                 $orderItem->quantity = $cartItem['quantity'];
                 $orderItem->price = $cartItem['price'];
                 $orderItem->discounted_price = $cartItem['discounted_price'];
                 $orderItem->created_at = date('Y-m-d h:i:s');
                 $orderItem->status = 'active';
                 $orderItem->save();
             }
             $order->status = 'pending';
             $order->save();
             Session::put('order_id', $order->id);
             echo json_encode(array('message' => 'done'));
         } else {
             echo json_encode(array('message' => 'exists'));
         }
     } else {
         echo json_encode(array('message' => 'invalid'));
     }
 }
开发者ID:ashutoshpandey,项目名称:course,代码行数:59,代码来源:CartController.php

示例10: actionOrder

 /**
  * Manages all models.
  */
 public function actionOrder($date = null, $cat = null, $show = 5, $location = null)
 {
     if (!$cat) {
         $cat = SnapUtil::config('boxomatic/supplier_product_feature_category');
     }
     $customerId = Yii::app()->user->user_id;
     $Customer = Customer::model()->findByPk($customerId);
     $deadlineDays = SnapUtil::config('boxomatic/orderDeadlineDays');
     if (!$date) {
         $date = DeliveryDate::getCurrentDeliveryDateId();
     }
     $updatedExtras = array();
     $updatedOrders = array();
     $Category = Category::model()->findByPk($cat);
     $DeliveryDate = DeliveryDate::model()->findByPk($date);
     $AllDeliveryDates = false;
     $pastDeadline = false;
     $CustDeliveryDate = false;
     if ($Customer) {
         $CustDeliveryDate = Order::model()->findByAttributes(array('delivery_date_id' => $date, 'user_id' => $customerId));
         if (!$CustDeliveryDate) {
             $CustDeliveryDate = new Order();
             $CustDeliveryDate->delivery_date_id = $date;
             $CustDeliveryDate->user_id = $customerId;
             $CustDeliveryDate->location_id = $Customer->location_id;
             $CustDeliveryDate->save();
         }
         $AllDeliveryDates = DeliveryDate::model()->with('Locations')->findAll("Locations.location_id = " . $CustDeliveryDate->location_id);
         $deadline = strtotime('+' . $deadlineDays . ' days');
         $pastDeadline = strtotime($DeliveryDate->date) < $deadline;
         if ($pastDeadline) {
             Yii::app()->user->setFlash('warning', 'Order deadline has passed, order cannot be changed.');
         }
     }
     if (!$Customer && (isset($_POST['supplier_purchases']) || isset($_POST['boxes']))) {
         Yii::app()->user->setFlash('error', 'You must register to make an order.');
         $this->redirect(array('site/register'));
     }
     if ($location) {
         $locationId = $location;
         $custLocationId = new CDbExpression('NULL');
         if (strpos($locationId, '-')) {
             //has a customer location
             $parts = explode('-', $locationId);
             $locationId = $parts[1];
             $custLocationId = $parts[0];
         }
         //$Location=Location::model()->findByPk($locationId);
         $CustDeliveryDate->location_id = $locationId;
         $CustDeliveryDate->customer_location_id = $custLocationId;
         $CustDeliveryDate->save();
         $CustDeliveryDate->refresh();
     }
     if (isset($_POST['btn_recurring'])) {
         $monthsAdvance = (int) $_POST['months_advance'];
         $startingFrom = $_POST['starting_from'];
         $every = $_POST['every'];
         $locationId = $_POST['Order']['delivery_location_key'];
         $custLocationId = new CDbExpression('NULL');
         if (strpos($locationId, '-')) {
             //has a customer location
             $parts = explode('-', $locationId);
             $locationId = $parts[1];
             $custLocationId = $parts[0];
         }
         $dayOfWeek = date('N', strtotime($CustDeliveryDate->DeliveryDate->date)) + 1;
         if ($dayOfWeek == 8) {
             $dayOfWeek = 1;
         }
         $orderedExtras = OrderItem::findCustomerExtras($customerId, $date);
         $orderedBoxes = UserBox::model()->with('Box')->findAllByAttributes(array('user_id' => $Customer->user_id), 'delivery_date_id=' . $date);
         $DeliveryDates = DeliveryDate::model()->findAll("\n\t\t\t\t\tdate >= '{$startingFrom}' AND\n\t\t\t\t\tdate <=  DATE_ADD('{$startingFrom}', interval {$monthsAdvance} MONTH) AND\n\t\t\t\t\tdate_sub(date, interval {$deadlineDays} day) > NOW() AND\n\t\t\t\t\tDAYOFWEEK(date) = '" . $dayOfWeek . "'");
         $n = 0;
         foreach ($DeliveryDates as $DD) {
             $CustDD = Order::model()->findByAttributes(array('delivery_date_id' => $DD->id, 'user_id' => $customerId));
             if (!$CustDD) {
                 $CustDD = new Order();
                 $CustDD->delivery_date_id = $DD->id;
                 $CustDD->user_id = $customerId;
                 $CustDD->location_id = $CustDeliveryDate->location_id;
                 $CustDD->save();
             }
             //Delete any extras already ordered
             $TBDExtras = OrderItem::findCustomerExtras($customerId, $DD->id);
             foreach ($TBDExtras as $TBDExtra) {
                 $TBDExtra->delete();
             }
             //Delete any extras already ordered
             $TBDBoxes = UserBox::model()->with('Box')->findAllByAttributes(array('user_id' => $Customer->user_id), 'delivery_date_id=' . $CustDD->delivery_date_id);
             foreach ($TBDBoxes as $TBDBox) {
                 $TBDBox->delete();
             }
             $n++;
             if ($n % 2 == 0 && $every == 'fortnight') {
                 continue;
             }
             //Copy current days order
//.........这里部分代码省略.........
开发者ID:snapfrozen,项目名称:boxomatic,代码行数:101,代码来源:OrderItemController.php

示例11: checkout

 public function checkout(Request $request)
 {
     $token = $request->input('stripeToken');
     //Retriieve cart information
     $cart = Cart::where('user_id', Auth::user()->id)->first();
     $items = $cart->cartItems;
     $total = 0;
     foreach ($items as $item) {
         $total += $item->product->price;
     }
     if (Auth::user()->charge($total * 100, ['source' => $token, 'receipt_email' => Auth::user()->email])) {
         $order = new Order();
         $order->total_paid = $total;
         $order->user_id = Auth::user()->id;
         $order->save();
         foreach ($items as $item) {
             $orderItem = new OrderItem();
             $orderItem->order_id = $order->id;
             $orderItem->product_id = $item->product->id;
             $orderItem->file_id = $item->product->file->id;
             $orderItem->save();
             CartItem::destroy($item->id);
         }
         return redirect('/order/' . $order->id);
     } else {
         return redirect('/cart');
     }
 }
开发者ID:xenxa,项目名称:essensanaturaleonline,代码行数:28,代码来源:OrderController.php

示例12: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Order();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     //        print_r($_POST);
     //        exit;
     if (!$_POST['delivery_address']) {
         echo '<script>alert("您还没有添加收货地址!")</script>';
         echo '<script type="text/javascript">history.go(-1)</script>';
         die;
     } else {
         if (isset($_POST)) {
             $model->attributes = $_POST;
             $model->order_id = F::get_order_id();
             $model->user_id = Yii::app()->user->id ? Yii::app()->user->id : '0';
             $model->create_time = time();
             $cri = new CDbCriteria(array('condition' => 'contact_id =' . $_POST['delivery_address'] . ' AND user_id = ' . Yii::app()->user->id));
             $address = AddressResult::model()->find($cri);
             $model->receiver_name = $address->contact_name;
             $model->receiver_country = $address->country;
             $model->receiver_state = $address->state;
             $model->receiver_city = $address->city;
             $model->receiver_district = $address->district;
             $model->receiver_address = $address->address;
             $model->receiver_zip = $address->zipcode;
             $model->receiver_mobile = $address->mobile_phone;
             $model->receiver_phone = $address->phone;
             if ($model->save()) {
                 $cart = Yii::app()->cart;
                 $mycart = $cart->contents();
                 foreach ($mycart as $mc) {
                     $OrderItem = new OrderItem();
                     $OrderItem->order_id = $model->order_id;
                     $OrderItem->item_id = $mc['id'];
                     $OrderItem->title = $mc['title'];
                     $OrderItem->pic_url = serialize($mc['pic_url']);
                     $OrderItem->sn = $mc['sn'];
                     $OrderItem->num = $mc['qty'];
                     $OrderItem->price = $mc['price'];
                     $OrderItem->amount = $mc['subtotal'];
                     $OrderItem->save();
                 }
                 $cart->destroy();
                 $this->redirect(array('success'));
             }
         }
     }
     //        $this->render('create', array(
     //            'model' => $model,
     //        ));
 }
开发者ID:jackycgq,项目名称:advanced,代码行数:56,代码来源:OrderController.php


注:本文中的OrderItem::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。