Skip to content

Feature: Guest checkout support #154

Description

@Daksh7785

Feature: Guest checkout support

Type: Feature / E-commerce
Track: Full Stack (React + Node.js Mock API)
Priority: High
Difficulty: Advanced

Problem statement

Requiring users to create an account before completing a purchase significantly increases checkout abandonment rates. Many users prefer a faster checkout experience, especially for one-time purchases. The current checkout flow (once implemented) should not require authentication in order to complete an order.

Description

Introduce a Guest Checkout pathway that allows unauthenticated users to complete purchases without creating an account.

When a user who is not logged in clicks Checkout, they should be presented with a Checkout Gateway that offers three options:

  • Log In

  • Create Account

  • Continue as Guest

The guest flow should collect only the information required to fulfill the order and send an order confirmation, such as shipping address and contact email. No password or account creation should be required.

Guest orders should be processed through the existing mock API architecture and be fully compatible with the current cart and checkout flow.

Important: Keep this Pull Request focused solely on guest checkout functionality. Avoid implementing payment gateways, account merging, or persistent order history for guest users.

Objective

Implement a guest checkout experience that allows unauthenticated users to complete orders without creating an account while preserving the existing authenticated checkout flow.

Scope

The implementation should include:

  • Checkout Gateway component

  • Guest checkout form

  • Independent guest checkout state

  • Order submission for guest users

  • Mock API integration

  • Validation for required shipping and contact information

  • Preserve authenticated checkout functionality

Functional requirements

Checkout gateway

When an unauthenticated user attempts to check out, display a gateway with three actions:

Checkout

Already have an account?

[ Log In ]

New here?

[ Create Account ]

Fast checkout without creating an account

[ Continue as Guest ]

Guest checkout flow

Guest users should provide:

Contact

  • Email address

  • Phone number (optional)

Shipping

  • Full name

  • Address line 1

  • Address line 2 (optional)

  • City

  • State

  • Postal code

  • Country

No password or authentication fields should be required.

Authenticated checkout

Authenticated users should:

  • Skip the gateway automatically.

  • Continue using their saved profile information.

  • Be able to edit shipping information if needed.

Guest order submission

Guest orders should:

  • Validate required fields.

  • Submit successfully to the mock API.

  • Display an order confirmation.

  • Include guest email for confirmation purposes.

Technical requirements

  • Follow the existing React architecture.

  • Keep guest state independent from authenticated user state.

  • Reuse existing checkout components where possible.

  • Prepare the architecture for future backend integration.

Required file changes

Existing files to modify

File Folder Purpose
Checkout.jsx bookshelf-frontend/src/pages/ Add guest checkout flow
CartDrawer.jsx bookshelf-frontend/src/components/ Route unauthenticated users to gateway
App.jsx or router bookshelf-frontend/src/ Add checkout gateway route if needed

Project structure impact

bookshelf-frontend/
└── src/
    ├── components/
    │   ├── CheckoutGateway.jsx
    │   └── GuestCheckoutForm.jsx
    ├── pages/
    │   └── Checkout.jsx
    └── ...

Minimal architectural impact.

Implementation details

Checkout gateway

Flow:

User clicks Checkout
         │
Authenticated?
    ┌────┴────┐
    │         │
   Yes        No
    │         │
Checkout   Checkout Gateway
               │
     ┌─────────┼─────────┐
     │         │         │
  Log In   Create Account  Guest
     │         │         │
     └─────────┼─────────┘
               │
           Checkout Form
               │
          Submit Order

Guest state management

Keep guest data separate from the authenticated user context.

Suggested state:

{
  email: "",
  fullName: "",
  address: {
    line1: "",
    line2: "",
    city: "",
    state: "",
    postalCode: "",
    country: ""
  }
}

Do not write guest information into the authenticated user store.

Order payload

Guest order example:

{
  "customerType": "guest",
  "email": "guest@example.com",
  "shippingAddress": {
    "fullName": "Jane Doe",
    "line1": "123 Main Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10001"
  },
  "items": [...],
  "total": 49.99
}

This should be compatible with the future backend API.

Validation

Validate:

  • Email format

  • Required shipping fields

  • Postal code

  • Country selection

  • Empty cart

  • Duplicate submissions

Display inline validation messages where appropriate.

Components affected

Frontend

  • Checkout

  • Cart Drawer

  • Authentication flow

  • Guest checkout form

Future backend

  • Order API

  • Guest order processing

  • Email confirmation

Dependencies

None required.

Reuse existing React and routing infrastructure.

Edge cases

  • Empty cart

  • Invalid email

  • Incomplete shipping address

  • Guest refreshes during checkout

  • Switching from guest to login

  • Switching from login to guest

  • Multiple rapid submissions

  • Network failure during order submission

Acceptance criteria

  • Unauthenticated users see a Checkout Gateway.

  • Gateway provides Login, Create Account, and Continue as Guest options.

  • Guest users can complete checkout without creating an account.

  • Guest form validates required fields.

  • Guest data is stored separately from authenticated user data.

  • Guest orders submit successfully to the mock API.

  • Existing authenticated checkout flow remains unchanged.

  • UI is responsive across devices.

Testing requirements

Manual testing

Guest flow

  • Open checkout while logged out.

  • Verify the Checkout Gateway appears.

  • Select Continue as Guest.

  • Complete the shipping form.

  • Submit the order.

  • Verify success confirmation.

Authenticated flow

  • Log in.

  • Open checkout.

  • Verify the gateway is skipped.

  • Confirm checkout behaves normally.

Validation

  • Submit invalid email.

  • Submit incomplete address.

  • Verify validation errors appear.

  • Prevent submission until valid.

Empty cart

  • Attempt guest checkout with an empty cart.

  • Verify appropriate messaging.

Regression

  • Cart functionality remains unchanged.

  • Authentication continues working.

  • Navigation behaves correctly.

  • Existing tests continue to pass.

Breaking changes

No

Guest checkout extends the checkout flow without affecting authenticated users.

Performance impact

Minimal.

Adds lightweight conditional rendering and guest form state.

Security considerations

  • Validate all guest input on the frontend.

  • Do not require or store passwords for guest users.

  • Do not expose internal API errors.

  • Sanitize user-provided shipping information.

  • Prepare the implementation for future backend validation.

Benefits

  • Reduces checkout abandonment.

  • Improves conversion rates.

  • Provides a faster purchase experience.

  • Supports one-time buyers.

  • Preserves the existing authenticated checkout flow.

  • Creates a scalable foundation for future e-commerce features.

Definition of done

  • Checkout Gateway implemented.

  • Guest checkout form implemented.

  • Guest state management implemented.

  • Validation completed.

  • Mock order submission implemented.

  • Authenticated flow preserved.

  • Manual testing completed.

  • Existing functionality unaffected.

  • Code follows project standards.

Suggested branch name

feature/guest-checkout-support

Labels

feature
frontend
react
checkout
guest
ecommerce
authentication
forms
validation
advanced

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions