Search code examples
djangoflutterdjango-rest-frameworke-commerce

Django Flutter Ecommerce Shopping Cart


I am attempting to build an ecommerce site with a functional shopping cart that does not require a user to login before adding/removing items. To add this functionality I plan to store information based around the user's device to remember their order history, current items in cart, etc. For this, I am using a python Django backend (Django Rest Framework) and a Dart Flutter front end.

This is going to be solely a web application to start and then cross into a mobile application, hence why I am using flutter.

My question is more of a general architecture question rather than specific coding. I have done a lot of research as to how to grab a device ID using the flutter front end and then send that device ID to the backend Django application through a cookie. My question is if this is the right direction to go?

Do I use flutter to create the cookie and then send it via POST request to the backend to manage the shopping cart? Or do I create the device ID through django backend some how?


Solution

  • In my opinion - to use "device ID" is a bad way to keep the cart information.

    Why:

    • it is not work without additional code if many users use the same device.
    • it is not work, if i want to be an "anonym customer".
    • it is not work, if i don't allow to get 'device id'.
    • it can be hacked, if i use 'device id' from other customer.

    Django gives you a good (not the best) possibility - to work with sessions. https://docs.djangoproject.com/en/4.1/topics/http/sessions/

    Probably you can use this possibility?