@haniabidkz If it’s a RESTful API, then you shouldn’t be relying on state. So, you should be creating a cart resource, and then using the identifier from that cart resource to add items to the cart. You can then associate the cart with a user if the user authenticates at a later time.
Adding guest data into cart [JWT REST API]
I am developing an eCommerce application rest API. This API will be consumed by mobile developers to build an e-commerce app.
I am facing an issue regarding the shopping cart, A user without being logged-in can add the data to the cart and the data will be stored in a database table named cart. Cart table has product, quantity, guest_id (For guest id), user_id(For authenticated user id) columns.
If logged-in user adds a product to the cart, his ID with cart data will be inserted in the table. But what about guest_id, How I can generate guest id, and where I can store it so it will remain the same and I will be able to access the guest cart data on the cart page?
Note: I am using JWT for authorization/authentication purpose and using core php.
Please or to participate in this conversation.