From 3f844e4e0699ff6221daa7d8701c859dcf085f5e Mon Sep 17 00:00:00 2001 From: Josh Ashton Date: Mon, 5 May 2025 21:53:39 -0600 Subject: [PATCH] finished final project --- catalog/cart.php | 22 ++ catalog/catalog.php | 4 +- catalog/components/bubbles.php | 7 + catalog/components/cart/checkout.php | 101 ++++++++ catalog/components/cart/confirmation.php | 28 +++ catalog/components/cart/item.php | 21 +- catalog/components/cart/layout.php | 25 ++ catalog/components/head.php | 35 +-- catalog/components/nav.php | 16 +- catalog/components/products/card.php | 12 +- catalog/components/products/grid.php | 2 +- catalog/components/products/list.php | 0 catalog/components/products/product.php | 17 +- catalog/components/user/login.php | 13 +- catalog/components/user/signup.php | 16 +- catalog/css/base.css | 286 ++++++++++++++++++++--- catalog/css/colors.css | 98 +++++++- catalog/functions/base.php | 15 ++ catalog/functions/catalog.php | 80 ++++++- catalog/functions/db.php | 13 +- catalog/functions/init.php | 4 + catalog/functions/user.php | 22 +- catalog/index.php | 27 ++- catalog/js/cart.js | 47 ++++ catalog/js/create-account.js | 70 +++--- catalog/js/index.js | 172 ++++++++++++++ catalog/js/login-modal.js | 31 --- catalog/js/login.js | 29 +++ catalog/js/product_page.js | 45 ++++ catalog/product.php | 4 +- catalog/scripts/init.sh | 1 - catalog/scripts/setup.sql | 43 ++-- 32 files changed, 1087 insertions(+), 219 deletions(-) create mode 100644 catalog/components/bubbles.php create mode 100644 catalog/components/cart/checkout.php create mode 100644 catalog/components/cart/confirmation.php create mode 100644 catalog/components/cart/layout.php delete mode 100644 catalog/components/products/list.php create mode 100644 catalog/js/cart.js create mode 100644 catalog/js/index.js delete mode 100644 catalog/js/login-modal.js create mode 100644 catalog/js/login.js create mode 100644 catalog/js/product_page.js delete mode 100755 catalog/scripts/init.sh 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 @@ +