diff --git a/catalog/cart.php b/catalog/cart.php index d70a86a..9d5c381 100755 --- a/catalog/cart.php +++ b/catalog/cart.php @@ -8,6 +8,28 @@ if (!isset($_SESSION['id'])) foreach (glob('components/cart/*.php') as $file) require_once $file; +require_once 'functions/catalog.php'; require_once 'components/head.php'; +if (empty($_SESSION['cart'])) { + echo ' +
+

Your cart is empty!

+

Check out our innovative and reliable products here.

+
+ '; +} else { + if (isset($_POST['form_id'])) { + $total = calculate_total(); + $items = []; + foreach ($_SESSION['cart'] as $id => $q) { + $items[fetch_product($id)['name']] = $q; + unset($_SESSION['cart'][$id]); + } + + echo cart_confirmation($_POST['fname'], $_POST['lname'], $_POST['add'], $_POST['city'], $_POST['state'], $_POST['zip'], $total, $items); + } else + echo cart_layout(); +} + require_once 'components/foot.php'; diff --git a/catalog/catalog.php b/catalog/catalog.php index 1c8bdee..2fc7b21 100755 --- a/catalog/catalog.php +++ b/catalog/catalog.php @@ -4,11 +4,11 @@ include_once 'functions/catalog.php'; // UI Components foreach (glob('components/products/*.php') as $file) - require_once $file; + require_once $file; include_once 'components/head.php'; -echo '

Catalog

'; +echo '

Catalog

'; echo '
'; echo catalog_grid(fetch_catalog()); diff --git a/catalog/components/bubbles.php b/catalog/components/bubbles.php new file mode 100644 index 0000000..19dac31 --- /dev/null +++ b/catalog/components/bubbles.php @@ -0,0 +1,7 @@ +'; + +for ($i = 0; $i < 50; $i++) + echo '
'; + +echo '
'; diff --git a/catalog/components/cart/checkout.php b/catalog/components/cart/checkout.php new file mode 100644 index 0000000..f27d91c --- /dev/null +++ b/catalog/components/cart/checkout.php @@ -0,0 +1,101 @@ + +
+ +
+
+ + +
+ +
+ + +
+
+ +
+ + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

' . format_money($total) . '

+ +
+
+ + '; + + return $checkout; +} diff --git a/catalog/components/cart/confirmation.php b/catalog/components/cart/confirmation.php new file mode 100644 index 0000000..99f7856 --- /dev/null +++ b/catalog/components/cart/confirmation.php @@ -0,0 +1,28 @@ + +

Shipping Details:

+

' . $fname . ' ' . $lname . '

+

' . $add . '

+

' . $city . ', ' . $state . ' ' . $zip . '

+
+

Your order will spontaneously appear before you, for you convenience!

+ We fold space and time itself, to ensure the best experience for our customers! +
+

Your Items:

+ +
Total: $' . $total . '
+ '; + + return $con; +} diff --git a/catalog/components/cart/item.php b/catalog/components/cart/item.php index 79c8484..2d78a6d 100644 --- a/catalog/components/cart/item.php +++ b/catalog/components/cart/item.php @@ -1,19 +1,18 @@ -
+
+

' . $item['name'] . '

+
+ + +
+ +
+
- -
-

' . $item['description'] . '

- - -
-
'; return $item; diff --git a/catalog/components/cart/layout.php b/catalog/components/cart/layout.php new file mode 100644 index 0000000..1a6febf --- /dev/null +++ b/catalog/components/cart/layout.php @@ -0,0 +1,25 @@ + +
+ '; + + foreach ($_SESSION['cart'] as $id => $q) { + $product = fetch_product($id); + $total += $product['price'] * $q; + $layout .= cart_item($product, $q); + } + + $layout .= ' +
+ ' . cart_checkout($total) . ' + + '; + + return $layout; +} diff --git a/catalog/components/head.php b/catalog/components/head.php index 75da5c7..3b97918 100644 --- a/catalog/components/head.php +++ b/catalog/components/head.php @@ -2,20 +2,27 @@ - - - '; - break; - case '/product.php': - if (!isset($_SESSION['id'])) - echo ''; - break; - } - ?> + + + + + '; + break; + case '/product.php': + echo ''; + break; + case '/cart.php': + echo ''; + break; + } + ?> - + diff --git a/catalog/components/nav.php b/catalog/components/nav.php index ec62844..b0683c2 100755 --- a/catalog/components/nav.php +++ b/catalog/components/nav.php @@ -1,6 +1,6 @@ +