Skip to content

[Feature Request]: Add a Shopping Cart with persistent state — products added to cart should survive page refresh #1003

Description

@prince-pokharna

Summary

Brownie Bliss is a bakery/food e-commerce project. If the site has a product listing or ordering capability, the shopping cart state should persist across page refreshes. Currently, if a user adds items to the cart and refreshes the page (or navigates away and returns), the cart is empty — this is a critical e-commerce UX failure.

Problem

  • Cart state is held only in React component state (or context), which is lost on every page reload.
  • Users who add items and then pause to read descriptions or navigate to another page lose their selections entirely.
  • For a food ordering platform, losing cart state mid-session is a direct conversion killer.
  • No localStorage persistence or session-based cart storage appears to be implemented.

Impact

  • Cart abandonment increases dramatically when users cannot trust that their selections will be remembered.
  • Multi-page browsing (product detail → cart → product detail) becomes frustrating as the cart empties on each navigation.

Proposed Solution

  1. Create a CartContext using React Context + useReducer for cart state management.
  2. Persist to localStorage on every cart state change using a useEffect:
   useEffect(() => {
     localStorage.setItem('brownie-cart', JSON.stringify(cartState));
   }, [cartState]);
  1. Rehydrate from localStorage on app initialization:
   const initialState = JSON.parse(localStorage.getItem('brownie-cart') || '[]');
  1. Add cart item count badge to the cart icon in the Navbar so users always know their cart status.
  2. Add a cart expiry (e.g., 24 hours) to automatically clear stale carts.

Additional Notes

  • I will implement the CartContext, persistence logic, Navbar badge, and a basic cart summary page.
  • Could you assign this to me?

Labels: enhancement, feature, ui/ux, good first issue, GSSoC 2026

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions