public function create() { Order::createOrder(); Customer::updateNotes(); OrderDetail::createOrderDetail(); Cart::deleteCartAfterCheckout(); parent::redirectTo('indexHome'); }
public function showOrderDetail($init, $id) { if ($init == 'admin') { $idData = explode('/', $_SERVER['REQUEST_URI']); $idAny = end($idData); parent::routes()->render('admin_order_detail.twig', array('app_base' => $this->appBase, 'results' => OrderDetail::showOrderDetail($id), 'title' => 'Order Details #' . $idAny)); } else { parent::routes()->render('order_detail.twig', array('app_base' => $this->appBase, 'carts' => Cart::countCart(), 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'is_order' => Order::countOrder(), 'results' => OrderDetail::showOrderDetail($id), 'title' => 'Your Order Details')); } }
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 show($id) { $flash = $this->app->view()->getData('flash'); $infoComment = ''; $infoCart = ''; if (isset($flash['infoComment'])) { $infoComment = $flash['infoComment']; } if (isset($flash['infoCart'])) { $infoCart = $flash['infoCart']; } parent::routes()->render('show_product.twig', array('app_base' => $this->appBase, 'bugs1' => true, 'carts' => Cart::countCart(), 'comments' => Comment::showComment($id), 'info_comment' => $infoComment, 'info_cart' => $infoCart, 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'is_order' => Order::countOrder(), 'results' => Product::showProduct($id), 'related_product' => Product::showRelatedProduct(Product::showProductCategory($id), $id), 'title' => Product::showProductName($id))); }
public function editCustomerProfile($email) { parent::routes()->render('edit_profile_customer.twig', array('app_base' => $this->appBase, 'carts' => Cart::countCart(), 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'results' => Customer::showCustomerByEmail($email), 'title' => 'Edit Profile')); }
public function delete($id) { Cart::deleteCart($id); parent::redirectTo('cart'); }
public function finalize($cart) { if (!empty($_POST)) { $rules = ['email' => FILTER_VALIDATE_EMAIL, 'address' => FILTER_SANITIZE_STRING]; //id customer //var_dump(\Connect::$pdo->lastInsertId()); $sanitize = filter_input_array(INPUT_POST, $rules); $error = false; if (!$sanitize['email']) { $_SESSION['error']['email'] = 'Votre email n\'est pas valide'; $error = true; } if (preg_match('/[0-9]{16}/', $_POST['number'], $m) !== 1 || strlen($_POST['number']) >= 17) { echo 'lol'; $_SESSION['error']['number'] = 'Votre numéro de carte bancaire n\'est pas valide'; $error = true; } if (!$sanitize['address']) { $_SESSION['error']['address'] = 'Votre adresse mail n\'est pas valide'; $error = true; } if ($error) { header('Location: /cart'); exit; } $history = new History(); $carts = new Cart(); foreach ($_SESSION['Star Wars'] as $name => $price) { $products[] = $carts->ShowCart($name); } foreach ($products as $product) { $data = ['name' => $product->title, 'product_id' => $product->id, 'numbercard' => $_POST['number'], 'address' => $_POST['address'], 'email' => $_POST['email'], 'price' => $product->price, 'total' => $_SESSION['Star Wars'][$product->title], 'quantity' => $_SESSION['Star Wars'][$product->title] / $product->price, 'date' => date("Y-m-d H:i:s")]; $history->create($data); } $_SESSION['message'] = 'Votre commande est terminé, veuillez checkez vos mails !'; $cart->reset(); header('Location: /'); } }
public function add() { parent::routes()->render('new_payment_confirmation.twig', array('app_base' => $this->appBase, 'carts' => Cart::countCart(), 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'is_order' => Order::countOrder(), 'orders' => Order::showOrderPaymentConfirmation(), 'title' => 'Payment Confirmation')); }