public function createOrder() { $sql = 'INSERT INTO orders(customer_id, status, total, created_at) SELECT customer_id, :status, :total, NOW() FROM customers WHERE customer_id = :customer_id'; $this->orders = parent::connect()->prepare($sql); $data = array('customer_id' => isset($_SESSION['idCustomer']) ? $_SESSION['idCustomer'] : null, 'status' => 'Pending', 'total' => Cart::totalCart()); try { $this->orders->execute($data); } catch (PDOException $e) { die($e->getMessage()); } }
public function index() { parent::routes()->render('index_cart.twig', array('app_base' => $this->appBase, 'carts' => Cart::countCart(), 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'results' => Cart::indexCart(), 'title' => 'Your Carts', 'total' => Cart::totalCart())); }