Login Cart Persistence - Django Wednesdays ECommerce 28

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ต.ค. 2024

ความคิดเห็น • 38

  • @Codemycom
    @Codemycom  7 หลายเดือนก่อน

    ▶ Watch Django Wednesdays Ecommerce Playlist ✅ Subscribe To My TH-cam Channel:
    bit.ly/3OBQJfN bit.ly/2IGzvOR
    ▶ See More At: ✅ Join My Facebook Group:
    Codemy.com bit.ly/2GFmOBz
    ▶ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
    Take 50% off with coupon code: youtube50 bit.ly/2VC9WUN
    ▶ Get The Code
    bit.ly/47xAhWJ

  • @fantasyworld1087
    @fantasyworld1087 7 หลายเดือนก่อน +1

    Hey John, I have been following you for two years. Firstly I have learnt your blog playlist. Then I started learning ecommerce from other source and also developed a project but my thirst was not satisfied. When I found your ecommerce playlist I started learning it. It's also awesome as blog playlist. I am thankful to you. I am actually a college teacher. I started learning programming just for fun but now it's my hobby and coding gives me pleaser. I think your teaching method makes it easy for us. Thank you very much. Keep teaching us as always in your style.

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน +1

      Thanks! I appreciate it!

  • @fantasyworld1087
    @fantasyworld1087 7 หลายเดือนก่อน +6

    Waiting for Checkout and payment gateway.

  • @БогданСокольников-т1н
    @БогданСокольников-т1н 7 หลายเดือนก่อน

    Two brilliant video's bro, waited for them!

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      Glad you liked them!

  • @deleos3744
    @deleos3744 7 หลายเดือนก่อน

    Very clear explanation

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      Thanks!

  • @alexallcool
    @alexallcool 7 หลายเดือนก่อน

    Hi @Codemycom and thank you so much for this detailed course! Will you make a video about how to customise/change CSS styles for this shopping project?

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      No, I'm not a design guy...we're learning the functionality of the thing, not how to make it look pretty.

  • @namdarcs
    @namdarcs 6 หลายเดือนก่อน

    Hey John, Sorry just catching up here from a couple weeks off! I think I may have noticed a bug with the persistent shopping cart... With the code we have implemented thus far it appears when we update the quantity from the view cart function and than log out and log back in... the quantity is not saved, it only shows last quantity item selected from adding to the cart function.... I went back between tutorials 15 and 19 to see if I perhaps made a mistake but I cant see any.... Do we want the cart quantity to retain if the user logouts after updating from there? Let me know I can clarify further if required :) Thanks for all the hard work here !

  • @joselucianocastro2836
    @joselucianocastro2836 หลายเดือนก่อน

    Hello, first of all, thank you for this great project, I don't know if what I'm suggesting is logical, but right now at this point I don't see it contemplated, the situation is, an anonymous user who registers 1 or more products logs in. the system and does not buy more products and logs out, what I observe is that the cart is not persisted in the database, of course I do not know if this should be corrected or is it the normal behavior of ecommerce. Greetings

    • @Codemycom
      @Codemycom  หลายเดือนก่อน +1

      No, an anonymous user can't log in. Logging in requires that you register. Your thing can't happen. If they aren't registered or logged in, then of course we don't want to save that to the database.

    • @joselucianocastro2836
      @joselucianocastro2836 หลายเดือนก่อน

      I haven't explained myself well, I'm sorry. What I mean is that a user adds 1 or more products to the cart, he logs into the system, and if within the system he does not add more products and then logs out, then we have a case in which, having added a product, he does not We have persisted in the database, of course the question was whether this operation would be logical? I have implemented this, an else to the if saved_cart:
      # Convert database string to python dicctionary
      if saved_cart:
      # Convert to dicctionary using JSON, para esto se importa libreria JSON
      #para que este json.loads() funciona se necesita tener este tipo de diccionario {"2":3, "5":1}
      converted_cart = json.loads(saved_cart)
      # Add the loaded cart dictionary to our session
      # Get the Cart
      cart = Cart(request)
      # Loop thru the cart and add items from the database {"3": 5, "1": 1}

      for key, value in converted_cart.items():
      #aqui se llama al metodo add de la clase Cart, pasando el product.id y quantity
      # cart.add(product=key, product_qty=value)
      # pero a ultima hora decide hacer otro metodo en la clase Cart
      cart.db_add(product=key, product_qty=value)
      """
      else:
      print("Me logo tengo productos siendo anonimo, este es el carro de la sesion", request.session.get('session_key'))
      # Get the Cart
      cart = request.session.get('session_key')

      # get the Current user Profile
      current_user = ProfileUser.objects.get(user=request.user)
      # Convert {'3':1, '2':3} to {"3":1, "2":3}
      carty = str(cart)
      carty = carty.replace("\'", "\"")
      print("carty es. ", carty)
      #Save the carty to the ProfileUser Model
      #current_user.update(old_cart=str(carty)) asi lo hace el
      current_user.old_cart = carty
      current_user.save()
      """

    • @joselucianocastro2836
      @joselucianocastro2836 หลายเดือนก่อน

      ​@@Codemycom I haven't explained myself well, I'm sorry. What I mean is, if a user adds one or more products to the cart, he logs into the system, within the system he does not add more products and immediately logs out, because we have a case in which, having added some product, he does not We have persisted it in the database, of course the question was whether this operation would be logical? I have implemented this, an else in case the old_cart field is empty:
      # Convert database string to python dicctionary
      if saved_cart:
      # Convert to dicctionary using JSON, para esto se importa libreria JSON
      #para que este json.loads() funciona se necesita tener este tipo de diccionario {"2":3, "5":1}
      converted_cart = json.loads(saved_cart)
      # Add the loaded cart dictionary to our session
      # Get the Cart
      cart = Cart(request)
      # Loop thru the cart and add items from the database {"3": 5, "1": 1}

      for key, value in converted_cart.items():
      #aqui se llama al metodo add de la clase Cart, pasando el product.id y quantity
      # cart.add(product=key, product_qty=value)
      # pero a ultima hora decide hacer otro metodo en la clase Cart
      cart.db_add(product=key, product_qty=value)
      """
      else:

      # Get the Cart
      cart = request.session.get('session_key')

      # get the Current user Profile
      current_user = ProfileUser.objects.get(user=request.user)
      # Convert {'3':1, '2':3} to {"3":1, "2":3}
      carty = str(cart)
      carty = carty.replace("\'", "\"")
      print("carty es. ", carty)
      #Save the carty to the ProfileUser Model
      #current_user.update(old_cart=str(carty))
      current_user.old_cart = carty
      current_user.save()
      """

    • @joselucianocastro2836
      @joselucianocastro2836 หลายเดือนก่อน

      I haven't explained myself well, I'm sorry. What I mean is, if a user adds one or more products to the cart, he logs into the system, within the system he does not add more products and immediately logs out, because we have a case in which, having added some product, he does not We have persisted it in the database, of course the question was whether this operation would be logical? I have implemented this, an else in case the old_cart field is empty:
      if saved_cart:
      # Convert to dicctionary using JSON, para esto se importa libreria JSON
      #para que este json.loads() funciona se necesita tener este tipo de diccionario {"2":3, "5":1}
      converted_cart = json.loads(saved_cart)
      # Add the loaded cart dictionary to our session
      # Get the Cart
      cart = Cart(request)
      # Loop thru the cart and add items from the database {"3": 5, "1": 1}

      for key, value in converted_cart.items():
      #aqui se llama al metodo add de la clase Cart, pasando el product.id y quantity
      # cart.add(product=key, product_qty=value)
      # pero a ultima hora decide hacer otro metodo en la clase Cart
      cart.db_add(product=key, product_qty=value)

      else:
      # Get the Cart
      cart = Cart(request).cart
      #cart = request.session.get('session_key')

      # get the Current user Profile
      current_user = ProfileUser.objects.get(user=request.user)
      # Convert {'3':1, '2':3} to {"3":1, "2":3}
      carty = str(cart)
      carty = carty.replace("\'", "\"")
      print("carty es. ", carty)
      #Save the carty to the ProfileUser Model
      #current_user.update(old_cart=str(carty)) asi lo hace el
      current_user.old_cart = carty
      current_user.save()

  • @horror3378
    @horror3378 7 หลายเดือนก่อน

    Good👍

  • @SalamiEdwin
    @SalamiEdwin 3 หลายเดือนก่อน

    Hi John,
    Still in the past a bit (based on how many videos I still need to complete to get to your most recent video). I however made an observation about this video. When I logout and add things to the cart, the things I add show in the cart when I log back in. Is that how you planned it to be or are we missing something?

    • @Codemycom
      @Codemycom  3 หลายเดือนก่อน

      We deal with that later in the playlist

    • @SalamiEdwin
      @SalamiEdwin 3 หลายเดือนก่อน

      @@Codemycom Alright, thanks🙏

  • @SabbirHMukul
    @SabbirHMukul 7 หลายเดือนก่อน

    how many video do you publish to complete ecommerce Django projects?

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      No clue, it'll go as long as I find interesting things to talk about.

  • @poslepepper
    @poslepepper 7 หลายเดือนก่อน

    Hi!
    Could you please show how to view others users profiles and same time be logged in for another user.
    Like: Iam Bob and want to see Johns and Marks profile, with their stuff.

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      No, that wouldn't be appropriate for an ecommerce app. People's shopping information is private. I have other Django playlists where we do that sort of thing.

    • @poslepepper
      @poslepepper 7 หลายเดือนก่อน

      Agree with you!
      I saw all the videos from the “Meeps”, can’t find it there too. Could you please send the link or tell in which playlists I can find it?

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      I have a half dozen django playlists here, I have no clue, look around@@poslepepper

  • @nishantkhorwal7078
    @nishantkhorwal7078 7 หลายเดือนก่อน

    Can we get a checkout and payment gateway fast pleaseee

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      It'll come when it comes lol

  • @vahid-m8b
    @vahid-m8b 7 หลายเดือนก่อน

    Do you have plans for online chat ؟For this course!

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน +1

      No, that's not really a core function of an ecommerce site.

    • @vahid-m8b
      @vahid-m8b 7 หลายเดือนก่อน

      @@Codemycom Thank you for your efforts, and i meant to talk between admin and buyers !

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน +1

      yes I understood what you meant, my answer doesn't change@@vahid-m8b

  • @sma1gdz
    @sma1gdz 7 หลายเดือนก่อน

    💙💙💙💚💚💚

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      🙂

  • @rxz7834
    @rxz7834 7 หลายเดือนก่อน

    Last.. 🙃

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      huh?

    • @rxz7834
      @rxz7834 7 หลายเดือนก่อน

      Younglings always try to be "First", so i decided to be last...

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน +1

      @@rxz7834 lol