Exemple #1
0
    if (isset($params['cart'])) {
        add_to_cart($app, $db, $params);
    } elseif (isset($params['wishlist'])) {
        add_to_wish_list($app, $db, $params);
    }
});
$app->get('/shop/checkout', $require_ssl, function () use($app, $db) {
    $app->view()->set_template('layouts/basic.php');
    $app->render('shop/checkout.php', array('page_title' => 'Checkout Options'));
});
$app->get('/shop/cccheckout', $require_ssl, function () use($app, $db) {
    $flash = $app->view()->getData('flash');
    if (!isset($flash['data'])) {
        $user = \Data\UserRepository::get_user_by_id($db, $_SESSION['user_id']);
        if ($user) {
            \Helpers\User::copy_user_to_flash($user);
        }
    }
    $checkout_errors = isset($flash['checkout_errors']) ? $flash['checkout_errors'] : array();
    $app->view()->set_template('layouts/basic.php');
    $app->render('shop/cccheckout.php', array('page_title' => 'Checkout', 'checkout_errors' => $checkout_errors));
});
$app->post('/shop/cccheckout', $require_ssl, function () use($app, $db, $config) {
    $cart = $app->view()->getData('cart');
    $data = $app->request()->post();
    if (isset($cart['messages']) && count($cart['messages'])) {
        $app->flash('checkout_errors', $cart['messages']);
        $app->flash('data', $data);
        $app->redirect($app->view()->url_secure('/shop/checkout'));
    }
    include BASE_URI . DS . 'routes' . DS . 'validators' . DS . 'checkout.php';