priceSolver = $priceSolver; $this->orderShopSolver = $orderShopSolver; } // getOrderDatas public function getDatas(OrderShopInterface $orderShop, UserInterface $user = null): array { $data = []; $data['order'] = $orderShop; if ($orderShop) { $data['count'] = $this->orderShopSolver->countQuantities($orderShop); $data['total_with_tax'] = $this->priceSolver->getTotalWithTax($orderShop); $data['order_products_by_category'] = $this->orderShopSolver->getOrderProductsByParentCategory($orderShop); $data['total_remaining_to_be_paid'] = $this->orderShopSolver->getTotalRemainingToBePaid($orderShop); } return $data; } public function getAsJsonObject(OrderShopInterface $orderShop): array { $data['id'] = $orderShop->getId(); $data['user'] = $orderShop->getUser()->getSummary(); $data['orderStatus'] = $orderShop->getOrderStatus()->__toString(); $data['deliveryAddress'] = $orderShop->getDeliveryAddress()->getSummary(); $data['invoiceAddress'] = $orderShop->getInvoiceAddress()->getSummary(); $data['total'] = $this->priceSolver->getTotal($orderShop); $data['totalWithTax'] = $this->priceSolver->getTotalWithTax($orderShop); $data['totalWithTaxAndReduction'] = $this->priceSolver->getTotalWithTax($orderShop); $i = 0; $orderProductsByParentCategory = $this->orderShopSolver->getOrderProductsByParentCategory($orderShop); foreach ($orderProductsByParentCategory as $labelCategory => $orderProducts) { foreach ($orderProducts as $orderProduct) { $data['orderProducts'][$i]['id'] = $orderProduct->getId(); $data['orderProducts'][$i]['product'] = $orderProduct->getProduct()->getId(); $data['orderProducts'][$i]['quantityOrder'] = $orderProduct->getQuantityOrder(); $data['orderProducts'][$i]['labelCategory'] = $labelCategory; $data['orderProducts'][$i]['title'] = $orderProduct->getTitle(); $data['orderProducts'][$i]['price'] = $this->priceSolver->getPrice($orderProduct); $data['orderProducts'][$i]['priceWithTax'] = $this->priceSolver->getPriceWithTax($orderProduct); $data['orderProducts'][$i]['priceWithTaxAndReduction'] = $this->priceSolver->getPriceWithTaxAndReduction( $orderProduct ); $data['orderProducts'][$i]['quantity'] = $orderProduct->getQuantityOrder(); $data['orderProducts'][$i]['totalWithTaxAndReduction'] = $this->priceSolver->getTotalOrderProductsWithTaxAndReduction( array($orderProduct) ); $i++; } } return $data; } }