Feature/Enhancement: Add Clear Cart button to Cart Page#555
Open
Denisha227 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 PR Title
Enhancement: Add Clear Cart button to Cart Page
closes (#554)
📌 Description
This PR addresses the inconvenience of having to remove items from the cart one by one. It introduces a "Clear Cart" button on the cart page that allows users to empty their cart completely with a single click.
With this update:
A "Clear Cart" button is visible at the top-right corner of the cart items list.
Clicking the button displays a confirmation dialog: "Are you sure you want to remove all items from your cart?"
Confirming the prompt removes all items from the cart instantly.
The cart page updates dynamically to show the "Your cart is empty 🛒" message.
When the cart is empty, the "Clear Cart" header is hidden, and the "Checkout" button is disabled.
✅ Changes Made
cart.html:
Layout: Added a .cart-list-header container containing the "Items in Cart" heading and the "Clear Cart" button above the items list.
Styling: Structured #clear-cart-btn with a modern, compact layout, incorporating smooth transition and lift animations on hover.
Logic: Implemented a confirmation step and wired it to window.cartManager.clear(). Updated renderCart() to show/hide the header and enable/disable the checkout button dynamically based on cart occupancy.
🎯 Benefits
Improved Usability: Users can empty large carts instantly instead of clicking "Remove" repeatedly.
Safer Actions: The confirmation dialog prevents accidental clears.
Clean Design: The button and header hide automatically when the cart is empty to avoid visual clutter.
📷 Screenshot
Before
After