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


PHP OrderDetail::createItems方法代码示例

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


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

示例1: processCart

 /**
  * @param CartRequest $request
  */
 public function processCart(CartRequest $request)
 {
     $re = array();
     if (Request::isMethod('post') && $request->all()) {
         //save user
         $user = new User();
         $uid = 0;
         $username = "";
         $email = "";
         $existUser = $user->getUserByEmail($request->get('email'));
         if (!empty($existUser)) {
             $uid = $existUser->id;
             $username = $existUser->name;
             $email = $existUser->email;
         } else {
             $item = array('name' => $request->get('name'), 'email' => $request->get('email'), 'phone' => $request->get('phone'), 'role' => BUYER);
             $createdUser = $user->createItem($item);
             $uid = $createdUser->id;
             $username = $createdUser->name;
             $email = $createdUser->email;
         }
         //save address receive
         $userReceive = new addressReceiveModel();
         $item2 = array('name' => $request->get('name_2'), 'phone' => $request->get('phone_2'), 'street' => $request->get('street'), 'city_id' => $request->get('city_id'), 'ward_id' => $request->get('ward_id'));
         $address = $userReceive->createItem($item2);
         if ($uid != 0 && $address) {
             //create user address
             $userAddress = new UserAddress();
             $option = array('user_id' => $uid, 'address_id' => $address->id);
             $userAddress->createItem($option);
             //create order and order detail
             $order = new Order();
             $orderAtt = array('user_id' => $uid, 'address_id' => $address->id, 'total' => Cart::total(), 'ship' => 0, 'address' => $address->street . ", " . addressWardModel::showName($address->ward_id) . ", " . addressCityModel::showName($address->city_id));
             $createdOrder = $order->createItem($orderAtt);
             $orderDetail = new OrderDetail();
             if ($orderDetail->createItems($createdOrder->id, Cart::content())) {
                 //send email
                 $data = array('username' => $username, 'linkWebsite' => SITE_LINK, 'receiveName' => $address->name, 'receiveAddress' => $createdOrder->address, 'receivePhone' => $address->phone, 'carts' => Cart::content(), 'total' => Cart::total());
                 Cart::destroy();
                 if ($this->sendEmailOrder($email, $username, $data)) {
                     $re = array('status' => 'ok', 'id' => $createdOrder->id);
                 } else {
                     $re = array('status' => 'error', 'message' => 'Bị lỗi trong quá trình gửi mail');
                 }
             }
         }
         echo json_encode($re);
     }
 }
开发者ID:kacana,项目名称:kacana.com,代码行数:52,代码来源:CartController.php


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