diff --git a/api/cart.php b/api/cart.php new file mode 100644 index 0000000..fae6b2b --- /dev/null +++ b/api/cart.php @@ -0,0 +1,79 @@ + $id, + 'name' => $name, + 'price' => (float)$price, + 'image' => $image, + 'quantity' => 1 + ]; + } + echo json_encode(['success' => true, 'cart_count' => getCartCount()]); + } else { + echo json_encode(['success' => false, 'error' => 'Invalid product']); + } + break; + + case 'remove': + $id = $_POST['id'] ?? null; + if ($id && isset($_SESSION['cart'][$id])) { + unset($_SESSION['cart'][$id]); + echo json_encode(['success' => true, 'cart_count' => getCartCount()]); + } else { + echo json_encode(['success' => false, 'error' => 'Product not in cart']); + } + break; + + case 'update': + $id = $_POST['id'] ?? null; + $quantity = (int)($_POST['quantity'] ?? 1); + if ($id && isset($_SESSION['cart'][$id])) { + if ($quantity <= 0) { + unset($_SESSION['cart'][$id]); + } else { + $_SESSION['cart'][$id]['quantity'] = $quantity; + } + echo json_encode(['success' => true, 'cart_count' => getCartCount()]); + } else { + echo json_encode(['success' => false, 'error' => 'Product not in cart']); + } + break; + + case 'get': + echo json_encode(['success' => true, 'cart' => array_values($_SESSION['cart']), 'cart_count' => getCartCount()]); + break; + + default: + echo json_encode(['success' => false, 'error' => 'Invalid action']); + break; +} \ No newline at end of file diff --git a/assets/css/custom.css b/assets/css/custom.css index 8a872e4..dd9ec9e 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -22,6 +22,12 @@ h1, h2, h3, .h1, .h2, .h3 { color: var(--ee-charcoal); } +/* Ensure headers inside white-text containers are visible */ +.text-white h1, .text-white h2, .text-white h3, +.hero-section h1, .hero-section h2, .hero-section h3 { + color: var(--ee-white) !important; +} + .bg-charcoal { background-color: var(--ee-charcoal) !important; } @@ -87,6 +93,18 @@ footer { padding: 60px 0; } +/* Zoom Effect */ +.zoom-container { + overflow: hidden; + border-radius: 8px; + border: 2px solid var(--ee-gold); +} + +.img-zoom-20 { + transform: scale(1.2); + transform-origin: center; +} + /* Senior Friendly Adjustments */ @media (max-width: 768px) { body { font-size: 1rem; } diff --git a/assets/images/pexels/jar-opener.jpg b/assets/images/pexels/jar-opener.jpg new file mode 100644 index 0000000..519c889 Binary files /dev/null and b/assets/images/pexels/jar-opener.jpg differ diff --git a/assets/images/pexels/pill-organizer.jpg b/assets/images/pexels/pill-organizer.jpg new file mode 100644 index 0000000..e77a9c3 Binary files /dev/null and b/assets/images/pexels/pill-organizer.jpg differ diff --git a/assets/js/main.js b/assets/js/main.js index 8fb2290..a668186 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,41 +1,132 @@ -function addToCart(product) { - alert(product + " has been added to your cart. We are still setting up our full checkout system!"); -} - -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', () => { + // Inquiry Form Handling const inquiryForm = document.getElementById('inquiryForm'); if (inquiryForm) { - inquiryForm.addEventListener('submit', function(e) { + inquiryForm.addEventListener('submit', async (e) => { e.preventDefault(); - const formData = new FormData(this); - const submitBtn = this.querySelector('button[type="submit"]'); + const formData = new FormData(inquiryForm); + const submitBtn = inquiryForm.querySelector('button[type="submit"]'); submitBtn.disabled = true; - submitBtn.textContent = 'Sending...'; + submitBtn.innerHTML = ' Sending...'; - fetch(this.action, { - method: 'POST', - body: formData - }) - .then(response => response.json()) - .then(data => { - if (data.success) { - alert('Thank you! We have received your inquiry.'); - const modal = bootstrap.Modal.getInstance(document.getElementById('inquiryModal')); - modal.hide(); - inquiryForm.reset(); + try { + const response = await fetch('/api/inquiry.php', { + method: 'POST', + body: formData + }); + const result = await response.json(); + + if (result.success) { + inquiryForm.innerHTML = `
+
+
Thank you, ${formData.get('name')}!
+

We have received your inquiry and will contact you shortly.

+
`; } else { - alert('Error: ' + data.error); + alert('Something went wrong. Please try again.'); + submitBtn.disabled = false; + submitBtn.innerHTML = 'Send Inquiry'; } - }) - .catch(error => { + } catch (error) { console.error('Error:', error); - alert('There was an error sending your inquiry.'); - }) - .finally(() => { + alert('Connection error. Please try again later.'); submitBtn.disabled = false; - submitBtn.textContent = 'Send Inquiry'; - }); + submitBtn.innerHTML = 'Send Inquiry'; + } }); } + + // Initialize cart count + updateCartCount(); }); + +function addToCart(id, name, price, image) { + const formData = new FormData(); + formData.append('id', id); + formData.append('name', name); + formData.append('price', price); + formData.append('image', image); + + fetch('/api/cart.php?action=add', { + method: 'POST', + body: formData + }) + .then(response => { + if (!response.ok) throw new Error('Network response was not ok'); + return response.json(); + }) + .then(data => { + if (data.success) { + updateCartCount(data.cart_count); + showToast(` ${name} added to cart!`); + } else { + console.error('API Error:', data.error); + } + }) + .catch(error => { + console.error('Error adding to cart:', error); + alert('Could not add item to cart. Please try again.'); + }); +} + +function updateCartCount(count = null) { + if (count !== null) { + renderCartCount(count); + return; + } + + fetch('/api/cart.php?action=get') + .then(response => response.json()) + .then(data => { + if (data.success) { + renderCartCount(data.cart_count); + } + }) + .catch(error => console.error('Error fetching cart count:', error)); +} + +function renderCartCount(count) { + const cartCountElement = document.getElementById('cart-count'); + if (cartCountElement) { + cartCountElement.innerText = count; + if (count > 0) { + cartCountElement.classList.remove('d-none'); + } else { + cartCountElement.classList.add('d-none'); + } + } +} + +function showToast(message) { + const toastContainer = document.getElementById('toast-container') || createToastContainer(); + const toast = document.createElement('div'); + toast.className = 'toast align-items-center text-white bg-charcoal border-0 show mb-2 shadow-lg'; + toast.role = 'alert'; + toast.ariaLive = 'assertive'; + toast.ariaAtomic = 'true'; + toast.innerHTML = ` +
+
+ ${message} +
+ +
+ `; + toastContainer.appendChild(toast); + + // Auto-remove after 4 seconds + setTimeout(() => { + toast.classList.remove('show'); + setTimeout(() => toast.remove(), 500); + }, 4000); +} + +function createToastContainer() { + const container = document.createElement('div'); + container.id = 'toast-container'; + container.className = 'toast-container position-fixed bottom-0 end-0 p-3'; + container.style.zIndex = '1100'; + document.body.appendChild(container); + return container; +} diff --git a/assets/pasted-20260129-055938-169c9b19.png b/assets/pasted-20260129-055938-169c9b19.png new file mode 100644 index 0000000..c553cc1 Binary files /dev/null and b/assets/pasted-20260129-055938-169c9b19.png differ diff --git a/assets/pasted-20260129-060533-24041dfc.png b/assets/pasted-20260129-060533-24041dfc.png new file mode 100644 index 0000000..aabf365 Binary files /dev/null and b/assets/pasted-20260129-060533-24041dfc.png differ diff --git a/assets/pasted-20260129-060739-18177018.png b/assets/pasted-20260129-060739-18177018.png new file mode 100644 index 0000000..2befa93 Binary files /dev/null and b/assets/pasted-20260129-060739-18177018.png differ diff --git a/assets/vm-shot-2026-01-29T05-58-17-342Z.jpg b/assets/vm-shot-2026-01-29T05-58-17-342Z.jpg new file mode 100644 index 0000000..1fc7b58 Binary files /dev/null and b/assets/vm-shot-2026-01-29T05-58-17-342Z.jpg differ diff --git a/assets/vm-shot-2026-01-29T06-04-56-060Z.jpg b/assets/vm-shot-2026-01-29T06-04-56-060Z.jpg new file mode 100644 index 0000000..11fa9d9 Binary files /dev/null and b/assets/vm-shot-2026-01-29T06-04-56-060Z.jpg differ diff --git a/cart.php b/cart.php new file mode 100644 index 0000000..180962f --- /dev/null +++ b/cart.php @@ -0,0 +1,172 @@ + + +
+
+
+

Your Cart

+

Review your safety essentials before checkout.

+
+ +
+ + +
+
+

Your cart is empty

+

It looks like you haven't added any safety essentials yet.

+ Browse Products +
+ +
+
+
+
+
+ + + + + + + + + + + $item): ?> + + + + + + + + +
ProductQuantityPrice
+
+ <?php echo htmlspecialchars($item['name']); ?> +
+
+ $ each +
+
+
+
+ + + +
+
+ $ + + +
+
+
+
+
+
+
+
+
Order Summary
+
+ Subtotal + $ +
+
+ Shipping + Free +
+
+ Estimated Tax + $0.00 +
+
+
+ Total + $ +
+ + +
+
+ + ElderEase Secure Checkout +
+
+ + Free shipping on all orders +
+
+
+
+
+
+ +
+ + + + + + \ No newline at end of file diff --git a/footer.php b/footer.php index d0bf92b..d5a7619 100644 --- a/footer.php +++ b/footer.php @@ -1,22 +1,33 @@ -