public function render() { if (!$this->wp->isUserLoggedIn()) { return Render::get('user/login', array()); } $order = $this->wp->getQueryParameter('orders'); $accountUrl = $this->wp->getPermalink($this->options->getPageId(Pages::ACCOUNT)); if (!empty($order) && is_numeric($order)) { $order = $this->orderService->find($order); /** @var Entity $order */ return Render::get('user/account/orders/single', array('messages' => $this->messages, 'order' => $order, 'myAccountUrl' => $accountUrl, 'listUrl' => Api::getEndpointUrl('orders', '', $accountUrl), 'showWithTax' => $this->options->get('tax.price_tax') == 'with_tax', 'getTaxLabel' => function ($taxClass) use($order) { return Tax::getLabel($taxClass, $order); })); } $customer = $this->customerService->getCurrent(); $orders = $this->orderService->findForUser($customer->getId()); return Render::get('user/account/orders', array('messages' => $this->messages, 'customer' => $customer, 'orders' => $orders, 'myAccountUrl' => $accountUrl)); }
/** * Finds orders for specified user. * * @param $userId int User ID. * @return array Orders found. */ public function findForUser($userId) { return $this->service->findForUser($userId); }