06_ShoppingCart_Task
06_ShoppingCart_Task
Description:
Students will develop a web page simulating a shopping cart with the following features:
1. Add Products:
Users can add products to the cart by selecting them from a predefined product list.
2. View Cart:
Display products added to the cart, including name, price, quantity, and subtotal. The
total amount should also be calculated.
3. Update Quantity:
Allow users to modify product quantities directly in the cart.
4. Remove Products:
Provide an option to delete specific products from the cart.
5. Save Cart:
Use cookies to save the cart's state between browser sessions.
Theme Features:
1. Change Theme:
Allow users to switch between at least two color themes (light and dark).
Technical Requirements:
3. JavaScript:
Project Structure:
• HTML:
o Create a product list with a button to add each product to the cart.
• CSS:
• JavaScript:
1. Saving Cookies:
javascript
document.cookie =
`cart=${encodeURIComponent(JSON.stringify(cart))}; path=/`;
document.cookie = `theme=${theme}; path=/`;
2. Expiration Dates:
2. Validation:
3. Dynamic Updates:
o Automatically refresh both the display and cookies when the cart is modified.
1. Responsive Design:
o Use flexbox or grid to ensure the product list and cart adapt to different screen
sizes.
2. Customizable Themes:
o Themes should impact the background, text color, and button styles.
css
.theme-light {
--bg-color: #fff;
--text-color: #000;
}
.theme-dark {
--bg-color: #333;
--text-color: #fff;
}
body {
background-color: var(--bg-color);
color: var(--text-color);
}
3. Control Buttons:
o Clear Cart: A button to completely empty the cart and clear cookies.
1. Animations:
2. Libraries:
o Allow (but do not require) the use of libraries like Bootstrap to simplify design.