break; case 'payment': if (cart_product_count() == 0) { redirect($app_path . 'cart'); } $card_number = ''; $card_cvv = ''; $card_expires = ''; $cc_number_message = ''; $cc_ccv_message = ''; $cc_expiration_message = ''; $billing_address = get_address($_SESSION['user']['billingAddressID']); include 'checkout_payment.php'; break; case 'process': if (cart_product_count() == 0) { redirect('Location: ' . $app_path . 'cart'); } $cart = cart_get_items(); $card_type = filter_input(INPUT_POST, 'card_type', FILTER_VALIDATE_INT); $card_number = filter_input(INPUT_POST, 'card_number'); $card_cvv = filter_input(INPUT_POST, 'card_cvv'); $card_expires = filter_input(INPUT_POST, 'card_expires'); $billing_address = get_address($_SESSION['user']['billingAddressID']); // Validate card data // NOTE: This uses functions from the util/validation.php file if ($card_type === false) { display_error('Card type is required.'); } elseif (!is_valid_card_type($card_type)) { display_error('Card type ' . $card_type . ' is invalid.'); }
function cart_get_item_word() { if (cart_product_count() == 1) { $item_word = 'Item'; } else { $item_word = 'Items'; } return $item_word; }
<!-- display most recent category --> <?php if (isset($_SESSION['last_category_id'])) { $category_url = '../catalog' . '?category_id=' . $_SESSION['last_category_id']; ?> <p>Return to: <a href="<?php echo $category_url; ?> "> <?php echo $_SESSION['last_category_name']; ?> </a></p> <?php } ?> <!-- if cart has items, display the Checkout link --> <?php if (cart_product_count() > 0) { ?> <p> Proceed to: <a href="../checkout">Checkout</a> </p> <?php } ?> </main> <?php include '../view/footer.php';