public function formSucceeded(Form $form, $values) { unset($values->agree); $values[CF::GEN_BUS_POSTING_GROUP] = 'NATIONAL'; $values[CF::VAT_BUS_POSTING_GROUP] = 'NATIONAL'; $values[CF::CUSTOMER_POSTING_GROUP] = 'DOMESTIC'; $values[CF::KEY] = $this->cus->Read($this->user->id)->{CF::KEY}; $values[CF::NO] = $this->user->id; $this->cus->Update($values); $order = new SalesOrder(); // $order->Bill_to_Customer_No = $this->user->id; $order->Sell_to_Customer_No = $this->user->id; // $order->VAT_Bus_Posting_Group = 'NATIONAL'; // $order->Currency_Code = 'EUR'; $lines = []; foreach ($this->shoppingCart->getAll() as $item) { $line = new SalesOrderLine(); $line->Type = 'Item'; $line->No = $item[ShoppingCart::KEY_FIELD]; $line->Quantity = $item[ShoppingCart::ORDER_QUANTITY_FIELD]; // $line->Line_Discount_Percent = '0.0'; // $line->Line_Discount_Amount = 0; // $line->Inv_Discount_Amount = 0; $lines[] = $line; } $order->SalesLines = $lines; $result = $this->sos->Create($order); if ($result) { foreach ($this->shoppingCart->getAll() as $item) { if (!$this->ics->ratingExists($this->user->id, $item[ShoppingCart::KEY_FIELD])) { $this->ics->addEmptyRating($this->user->id, $item[ShoppingCart::KEY_FIELD]); } } $this->shoppingCart->clear(); $this->onSuccess($values); } else { } }
public function handleRemoveAll($key) { $this->shoppingCart->remove($key); $this->onRemove($key); }
/** * * @SWG\Api( * path="/shopping_cart/delete", * @SWG\Operation( * method="POST", summary="删除购物车", notes="删除购物车", * @SWG\ResponseMessage(code=0, message="成功"), * @SWG\Parameter( * name="goods_list", * description="要修改的商品列表", * paramType="body", * required=true, * type="deleteShoppingCartParams" * ) * ) * ) */ public function delete(Request $request) { $response = new BaseResponse(); $content = json_decode($request->getContent(false)); $content = $content->goods_list; foreach ($content as $v) { $shoppingCart = ShoppingCart::find($v->id); if ($shoppingCart != null) { $shoppingCart->delete(); } } return $response->toJson(); }
public function beforeRender() { $this->template->shoppingCartItems = $this->shoppingCart->getItemsCount(); }