public function comment($params) { if (!empty($params['comments'])) { $sendEmail = array_pull($params, 'send_to_customer'); array_set($params, 'name', \Veer\Models\OrderStatus::where('id', '=', array_get($params, 'status_id'))->pluck('name')); \Veer\Models\OrderHistory::create($params + ['order_cache' => '']); if (!empty($sendEmail)) { $this->sendEmailOrdersStatus(array_get($params, 'orders_id'), ["history" => $params]); } } return $this; }
/** * make Order */ protected function makeOrder() { $cart = $this->showUser->getUserCart(app('veer')->siteId, \Auth::id(), app('session')->getId()); // rules if (\Auth::id() <= 0 && \Input::get('email') == null || $cart->count() <= 0) { \Session::flash('errorMessage', \Lang::get('veershop.order.error')); return \Redirect::route('user.cart.show'); } $grouped = app('veershop')->regroupShoppingCart($cart); $book = null; if (\Input::get('userbook_id') != null) { $book = \Veer\Models\UserBook::find(\Input::get('userbook_id')); } if (\Input::get('book.address') != null) { $book = app('veershop')->updateOrNewBook(\Input::get('book')); } list($order, $checkDiscount, $calculations) = app('veershop')->prepareOrder($grouped, $book, \Input::get('shipping_id'), \Input::get('payment_id'), false); $statusName = \Veer\Models\OrderStatus::where('id', '=', $order->status_id)->pluck('name'); \Veer\Models\OrderHistory::create(array("orders_id" => $order->id, "status_id" => $order->status_id, "name" => !empty($statusName) ? $statusName : '', "comments" => "")); $order->save(); if (isset($checkDiscount) && is_object($checkDiscount)) { app('veershop')->changeUserDiscountStatus($checkDiscount); } //app('veershop')->sendEmailOrderNew($order); // clear cart $this->showUser->getUserLists(app('veer')->siteId, \Auth::id(), app('session')->getId(), '[basket]', false)->delete(); \Session::put('successfulOrder', $order->id); return \Redirect::route('order.success'); }
public function status($history) { array_set($history, 'orders_id', $this->id); array_set($history, 'name', \Veer\Models\OrderStatus::where('id', '=', array_get($history, 'status_id'))->pluck('name')); if (empty($history['name'])) { $history['name'] = '[?]'; } $update = ['status_id' => array_get($history, 'status_id')]; $progress = array_pull($history, 'progress'); if (!empty($progress)) { $update['progress'] = $progress; } $sendEmail = array_pull($history, 'send_to_customer'); \Veer\Models\OrderHistory::create($history); \Veer\Models\Order::where('id', '=', $this->id)->update($update); if (!empty($sendEmail)) { $this->sendEmailOrdersStatus($this->id, ['history' => $history]); } return $this; }