diff --git a/src/controller/order/Order.php b/src/controller/order/Order.php index 6c81133..183127b 100644 --- a/src/controller/order/Order.php +++ b/src/controller/order/Order.php @@ -43,7 +43,10 @@ final class Order extends AbstractDefaultController implements OrderInterface } private function store(): void - {} + { + $this->core->getBasket()->setCustomer($this->core->getUser()); + $this->core->setBasket(new OrderEntity()); + } public function basket(): void { @@ -62,12 +65,7 @@ final class Order extends AbstractDefaultController implements OrderInterface $this->addProduct(); } if ($this->post['store']){ - $this->core->getBasket()->setCustomer($this->core->getUser()); - if($this->orderRepository->saveOrder($this->core->getBasket())){ - $this->core->setBasket(new OrderEntity()); - }else{ - throw new \Exception('Order could not be saved!'); - } + $this->store(); } } } diff --git a/src/repository/order/Order.php b/src/repository/order/Order.php index 9214c05..c65e7c6 100644 --- a/src/repository/order/Order.php +++ b/src/repository/order/Order.php @@ -16,7 +16,7 @@ final class Order extends AbstractRepository implements OrderInterface $this->database->beginTransaction(); $this->saveOrderEntity($order); $this->saveConnection($order); - return $this->database->rollBack(); + return $this->database->commit(); } /**