Skip to content

BUG:Error when adding item if user cart does not exist in ecommerce cart controllers #297

@sy875

Description

@sy875

Describe the bug

The addItemOrUpdateItemQuantity API assumes that a user always has a cart.
If the user has no cart yet, the API throws an error when trying to access cart.items

To Reproduce

Ensure the user has no cart in the database.
Call the Add Item to Cart API.
Observe the error: Cannot read property 'items' of null.

Expected behavior

If the user does not have a cart, a new cart should be created automatically and the product should be added successfully.

Screenshots

Image

OS

windows

OS Version

11

Client

Postman

Additional context or Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions