with the contents of cart submissions and contact form submissions
I'll unscramble the code and provide a clean version. Here's the properly organized website code:
I'll modify the code to only show the checkout button when there are items in the cart. Here are the changes:
The key changes are:
updateCheckoutButton() function to show/hide based on cart itemsHere's a fancier version with animations, transitions, and better UI/UX:
The key improvements include:
Here's the enhanced version with a fully functional cart system that shows items, quantities, and allows removal:
Key cart features added:
The cart now fully tracks:
Here's the complete, properly formatted code for your BRM Prints e-commerce website with a working shopping cart:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BRM Prints - Premium 3D Printers & Filaments</title>
<style>
:root {
--primary: #4361ee;
--secondary: #3a0ca3;
--accent: #f72585;
--dark: #1a1a2e;
--light: #f8f9fa;
--success: #4cc9f0;
--warning: #f8961e;
--danger: #ef233c;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body {
background-color: var(--light);
color: var(--dark);
line-height: 1.6;
}
header {
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
z-index: 1000;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.logo {
font-size: 1.8rem;
font-weight: 700;
}
.cart-icon {
display: flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
position: relative;
padding: 0.5rem 1rem;
background-color: rgba(255,255,255,0.2);
border-radius: 50px;
transition: all 0.3s ease;
}
.cart-icon:hover {
background-color: rgba(255,255,255,0.3);
}
.cart-count {
background-color: var(--accent);
border-radius: 50%;
padding: 0.2rem 0.6rem;
font-size: 0.9rem;
font-weight: 600;
}
.products {
padding: 3rem 1rem;
max-width: 1200px;
margin: 0 auto;
}
.product-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 2rem;
}
.product-card {
background-color: white;
border-radius: 10px;
padding: 1.5rem;
text-align: center;
transition: all 0.3s ease;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.product-card img {
max-width: 100%;
height: 150px;
object-fit: contain;
margin-bottom: 1rem;
}
.price {
font-weight: bold;
color: var(--accent);
font-size: 1.2rem;
margin: 0.5rem 0;
}
.add-to-cart {
background: linear-gradient(to right, var(--primary), var(--secondary));
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s ease;
width: 100%;
}
.add-to-cart:hover {
opacity: 0.9;
}
/* Cart Overlay Styles */
.cart-overlay {
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
display: none;
justify-content: flex-end;
z-index: 2000;
}
.cart-sidebar {
width: 100%;
max-width: 400px;
height: 100%;
background-color: white;
padding: 2rem;
overflow-y: auto;
}
.cart-item {
display: flex;
margin-bottom: 1rem;
padding-bottom: 1rem;
border-bottom: 1px solid #eee;
}
.cart-item img {
width: 80px;
height: 80px;
object-fit: contain;
margin-right: 1rem;
}
.cart-item-details {
flex: 1;
text-align: left;
}
.remove-item {
color: var(--danger);
background: none;
border: none;
cursor: pointer;
}
/* Responsive Styles */
@media (max-width: 768px) {
header {
flex-direction: column;
text-align: center;
}
.product-grid {
grid-template-columns: 1fr;
}
.cart-sidebar {
max-width: 100%;
}
}
</style>
</head>
<body>
<header>
<div class="logo">BRM Prints</div>
<div class="cart-icon">
🛒 <span class="cart-count">0</span>
</div>
</header>
<main>
<section class="products">
<h2>3D Printers</h2>
<div class="product-grid">
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=S1+Max" alt="S1 Max">
<h3>S1 Max</h3>
<p class="price">$499.99</p>
<button class="add-to-cart" data-product="S1 Max" data-price="499.99" data-image="https://via.placeholder.com/300x200?text=S1+Max">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=S1+Pro" alt="S1 Pro">
<h3>S1 Pro</h3>
<p class="price">$399.99</p>
<button class="add-to-cart" data-product="S1 Pro" data-price="399.99" data-image="https://via.placeholder.com/300x200?text=S1+Pro">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=S1+Mini" alt="S1 Mini">
<h3>S1 Mini</h3>
<p class="price">$299.99</p>
<button class="add-to-cart" data-product="S1 Mini" data-price="299.99" data-image="https://via.placeholder.com/300x200?text=S1+Mini">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=K1+Max" alt="K1 Max">
<h3>K1 Max</h3>
<p class="price">$599.99</p>
<button class="add-to-cart" data-product="K1 Max" data-price="599.99" data-image="https://via.placeholder.com/300x200?text=K1+Max">Add to Cart</button>
</div>
</div>
</section>
<section class="products">
<h2>Filaments</h2>
<div class="product-grid">
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=PLA+Filament" alt="PLA Filament">
<h3>PLA Filament</h3>
<p class="price">$24.99</p>
<button class="add-to-cart" data-product="PLA Filament" data-price="24.99" data-image="https://via.placeholder.com/300x200?text=PLA+Filament">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=ABS+Filament" alt="ABS Filament">
<h3>ABS Filament</h3>
<p class="price">$29.99</p>
<button class="add-to-cart" data-product="ABS Filament" data-price="29.99" data-image="https://via.placeholder.com/300x200?text=ABS+Filament">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=PETG+Filament" alt="PETG Filament">
<h3>PETG Filament</h3>
<p class="price">$27.99</p>
<button class="add-to-cart" data-product="PETG Filament" data-price="27.99" data-image="https://via.placeholder.com/300x200?text=PETG+Filament">Add to Cart</button>
</div>
</div>
</section>
</main>
<!-- Cart Overlay -->
<div class="cart-overlay">
<div class="cart-sidebar">
<h2>Your Cart</h2>
<div id="cart-items-container"></div>
<div id="cart-total">Total: $0.00</div>
<button id="checkout-btn">Proceed to Checkout</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const cart = [];
const cartCount = document.querySelector('.cart-count');
const cartOverlay = document.querySelector('.cart-overlay');
const cartItemsContainer = document.getElementById('cart-items-container');
const cartTotal = document.getElementById('cart-total');
const cartIcon = document.querySelector('.cart-icon');
const addToCartButtons = document.querySelectorAll('.add-to-cart');
const checkoutBtn = document.getElementById('checkout-btn');
// Toggle cart visibility
cartIcon.addEventListener('click', () => {
cartOverlay.style.display = 'flex';
renderCart();
});
// Close cart when clicking outside
cartOverlay.addEventListener('click', (e) => {
if (e.target === cartOverlay) {
cartOverlay.style.display = 'none';
}
});
// Add to cart functionality
addToCartButtons.forEach(button => {
button.addEventListener('click', () => {
const product = button.dataset.product;
const price = parseFloat(button.dataset.price);
const image = button.dataset.image;
// Check if product already in cart
const existingItem = cart.find(item => item.product === product);
if (existingItem) {
existingItem.quantity += 1;
} else {
cart.push({
product,
price,
image,
quantity: 1
});
}
updateCartCount();
showAddedToCart(product);
});
});
// Render cart items
function renderCart() {
if (cart.length === 0) {
cartItemsContainer.innerHTML = '<p>Your cart is empty</p>';
cartTotal.textContent = 'Total: $0.00';
return;
}
cartItemsContainer.innerHTML = '';
let total = 0;
cart.forEach((item, index) => {
const itemElement = document.createElement('div');
itemElement.className = 'cart-item';
itemElement.innerHTML = `
<img src="${item.image}" alt="${item.product}">
<div class="cart-item-details">
<h4>${item.product}</h4>
<p>$${item.price.toFixed(2)} x ${item.quantity}</p>
<p>$${(item.price * item.quantity).toFixed(2)}</p>
<button class="remove-item" data-index="${index}">Remove</button>
</div>
`;
cartItemsContainer.appendChild(itemElement);
total += item.price * item.quantity;
});
cartTotal.textContent = `Total: $${total.toFixed(2)}`;
// Add event listeners to remove buttons
document.querySelectorAll('.remove-item').forEach(button => {
button.addEventListener('click', (e) => {
const index = parseInt(e.target.dataset.index);
cart.splice(index, 1);
updateCartCount();
renderCart();
});
});
}
// Update cart count
function updateCartCount() {
const itemCount = cart.reduce((total, item) => total + item.quantity, 0);
cartCount.textContent = itemCount;
}
// Show added to cart notification
function showAddedToCart(product) {
alert(`${product} added to cart!`);
}
// Checkout functionality
checkoutBtn.addEventListener('click', () => {
if (cart.length === 0) return;
const orderSummary = cart.map(item =>
`${item.product} (${item.quantity}) - $${(item.price * item.quantity).toFixed(2)}`
).join('\n');
const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0);
alert(`Order Summary:\n\n${orderSummary}\n\nTotal: $${total.toFixed(2)}`);
// In a real app, you would process the payment here
cart.length = 0;
updateCartCount();
renderCart();
cartOverlay.style.display = 'none';
});
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BRM Prints - Premium 3D Printers & Filaments</title>
<style>
:root {
--primary: #4361ee;
--secondary: #3a0ca3;
--accent: #f72585;
--dark: #1a1a2e;
--light: #f8f9fa;
--success: #4cc9f0;
--warning: #f8961e;
--danger: #ef233c;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body {
background-color: var(--light);
color: var(--dark);
line-height: 1.6;
}
header {
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
z-index: 1000;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.logo {
font-size: 1.8rem;
font-weight: 700;
}
.cart-icon {
display: flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
position: relative;
padding: 0.5rem 1rem;
background-color: rgba(255,255,255,0.2);
border-radius: 50px;
transition: all 0.3s ease;
}
.cart-icon:hover {
background-color: rgba(255,255,255,0.3);
}
.cart-count {
background-color: var(--accent);
border-radius: 50%;
padding: 0.2rem 0.6rem;
font-size: 0.9rem;
font-weight: 600;
}
.products {
padding: 3rem 1rem;
max-width: 1200px;
margin: 0 auto;
}
.product-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 2rem;
}
.product-card {
background-color: white;
border-radius: 10px;
padding: 1.5rem;
text-align: center;
transition: all 0.3s ease;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.product-card img {
max-width: 100%;
height: 150px;
object-fit: contain;
margin-bottom: 1rem;
}
.price {
font-weight: bold;
color: var(--accent);
font-size: 1.2rem;
margin: 0.5rem 0;
}
.add-to-cart {
background: linear-gradient(to right, var(--primary), var(--secondary));
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s ease;
width: 100%;
}
.add-to-cart:hover {
opacity: 0.9;
}
/* Cart Overlay Styles */
.cart-overlay {
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
display: none;
justify-content: flex-end;
z-index: 2000;
}
.cart-sidebar {
width: 100%;
max-width: 400px;
height: 100%;
background-color: white;
padding: 2rem;
overflow-y: auto;
}
.cart-item {
display: flex;
margin-bottom: 1rem;
padding-bottom: 1rem;
border-bottom: 1px solid #eee;
}
.cart-item img {
width: 80px;
height: 80px;
object-fit: contain;
margin-right: 1rem;
}
.cart-item-details {
flex: 1;
text-align: left;
}
.remove-item {
color: var(--danger);
background: none;
border: none;
cursor: pointer;
}
/* Responsive Styles */
@media (max-width: 768px) {
header {
flex-direction: column;
text-align: center;
}
.product-grid {
grid-template-columns: 1fr;
}
.cart-sidebar {
max-width: 100%;
}
}
</style>
</head>
<body>
<header>
<div class="logo">BRM Prints</div>
<div class="cart-icon">
🛒 <span class="cart-count">0</span>
</div>
</header>
<main>
<section class="products">
<h2>3D Printers</h2>
<div class="product-grid">
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=S1+Max" alt="S1 Max">
<h3>S1 Max</h3>
<p class="price">$499.99</p>
<button class="add-to-cart" data-product="S1 Max" data-price="499.99" data-image="https://via.placeholder.com/300x200?text=S1+Max">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=S1+Pro" alt="S1 Pro">
<h3>S1 Pro</h3>
<p class="price">$399.99</p>
<button class="add-to-cart" data-product="S1 Pro" data-price="399.99" data-image="https://via.placeholder.com/300x200?text=S1+Pro">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=S1+Mini" alt="S1 Mini">
<h3>S1 Mini</h3>
<p class="price">$299.99</p>
<button class="add-to-cart" data-product="S1 Mini" data-price="299.99" data-image="https://via.placeholder.com/300x200?text=S1+Mini">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=K1+Max" alt="K1 Max">
<h3>K1 Max</h3>
<p class="price">$599.99</p>
<button class="add-to-cart" data-product="K1 Max" data-price="599.99" data-image="https://via.placeholder.com/300x200?text=K1+Max">Add to Cart</button>
</div>
</div>
</section>
<section class="products">
<h2>Filaments</h2>
<div class="product-grid">
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=PLA+Filament" alt="PLA Filament">
<h3>PLA Filament</h3>
<p class="price">$24.99</p>
<button class="add-to-cart" data-product="PLA Filament" data-price="24.99" data-image="https://via.placeholder.com/300x200?text=PLA+Filament">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=ABS+Filament" alt="ABS Filament">
<h3>ABS Filament</h3>
<p class="price">$29.99</p>
<button class="add-to-cart" data-product="ABS Filament" data-price="29.99" data-image="https://via.placeholder.com/300x200?text=ABS+Filament">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://via.placeholder.com/300x200?text=PETG+Filament" alt="PETG Filament">
<h3>PETG Filament</h3>
<p class="price">$27.99</p>
<button class="add-to-cart" data-product="PETG Filament" data-price="27.99" data-image="https://via.placeholder.com/300x200?text=PETG+Filament">Add to Cart</button>
</div>
</div>
</section>
</main>
<!-- Cart Overlay -->
<div class="cart-overlay">
<div class="cart-sidebar">
<h2>Your Cart</h2>
<div id="cart-items-container"></div>
<div id="cart-total">Total: $0.00</div>
<button id="checkout-btn">Proceed to Checkout</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const cart = [];
const cartCount = document.querySelector('.cart-count');
const cartOverlay = document.querySelector('.cart-overlay');
const cartItemsContainer = document.getElementById('cart-items-container');
const cartTotal = document.getElementById('cart-total');
const cartIcon = document.querySelector('.cart-icon');
const addToCartButtons = document.querySelectorAll('.add-to-cart');
const checkoutBtn = document.getElementById('checkout-btn');
// Toggle cart visibility
cartIcon.addEventListener('click', () => {
cartOverlay.style.display = 'flex';
renderCart();
});
// Close cart when clicking outside
cartOverlay.addEventListener('click', (e) => {
if (e.target === cartOverlay) {
cartOverlay.style.display = 'none';
}
});
// Add to cart functionality
addToCartButtons.forEach(button => {
button.addEventListener('click', () => {
const product = button.dataset.product;
const price = parseFloat(button.dataset.price);
const image = button.dataset.image;
// Check if product already in cart
const existingItem = cart.find(item => item.product === product);
if (existingItem) {
existingItem.quantity += 1;
} else {
cart.push({
product,
price,
image,
quantity: 1
});
}
updateCartCount();
showAddedToCart(product);
});
});
// Render cart items
function renderCart() {
if (cart.length === 0) {
cartItemsContainer.innerHTML = '<p>Your cart is empty</p>';
cartTotal.textContent = 'Total: $0.00';
return;
}
cartItemsContainer.innerHTML = '';
let total = 0;
cart.forEach((item, index) => {
const itemElement = document.createElement('div');
itemElement.className = 'cart-item';
itemElement.innerHTML = `
<img src="${item.image}" alt="${item.product}">
<div class="cart-item-details">
<h4>${item.product}</h4>
<p>$${item.price.toFixed(2)} x ${item.quantity}</p>
<p>$${(item.price * item.quantity).toFixed(2)}</p>
<button class="remove-item" data-index="${index}">Remove</button>
</div>
`;
cartItemsContainer.appendChild(itemElement);
total += item.price * item.quantity;
});
cartTotal.textContent = `Total: $${total.toFixed(2)}`;
// Add event listeners to remove buttons
document.querySelectorAll('.remove-item').forEach(button => {
button.addEventListener('click', (e) => {
const index = parseInt(e.target.dataset.index);
cart.splice(index, 1);
updateCartCount();
renderCart();
});
});
}
// Update cart count
function updateCartCount() {
const itemCount = cart.reduce((total, item) => total + item.quantity, 0);
cartCount.textContent = itemCount;
}
// Show added to cart notification
function showAddedToCart(product) {
alert(`${product} added to cart!`);
}
// Checkout functionality
checkoutBtn.addEventListener('click', () => {
if (cart.length === 0) return;
const orderSummary = cart.map(item =>
`${item.product} (${item.quantity}) - $${(item.price * item.quantity).toFixed(2)}`
).join('\n');
const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0);
alert(`Order Summary:\n\n${orderSummary}\n\nTotal: $${total.toFixed(2)}`);
// In a real app, you would process the payment here
cart.length = 0;
updateCartCount();
renderCart();
cartOverlay.style.display = 'none';
});
});
</script>
</body>
</html>
This complete solution includes:
The cart system now properly:
./src/App.js SyntaxError: /Users/carryme/Desktop/Product1/src/App.js: Unexpected token, expected "}" (24:18)
22 | ))}
23 | >
24 | {originals.map((item) => (
| ^
25 | <img
26 | className="row__poster row__posterLarge"
27 | src={${base_url}${item.poster_path}}
error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.*