Add Up Cart Totals - Django Wednesdays ECommerce 19

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.ค. 2024
  • In this video we'll add a Cart Total to our Shopping Cart Summary Page.
    As items get added, changed, and deleted from our Shopping Cart, we need to keep a running total of the amount of money in the cart.
    We also need to determine if an item is on sale, and add accordingly..
    #django #codemy #JohnElder
    Timecodes
    0:00​​ - Introduction
    1:04 - Add Totals Prompt
    2:30 - Add Totals To Views.py
    2:52 - Create Total In Cart.py
    3:46 - Get Products From DB
    5:05 - Add Up Running Total
    7:59 - Add Total To Cart Summary Page
    8:25 - On Sale Price
    10:18 - Conclusion

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

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

    ▶ 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

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

    Thanks so much John! once again great video :)

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

      Glad you liked it!

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

    Best wishes and a Happy New Year, my friend! I wish you lots of content in the new year. 😁❤

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

      Thanks! To you too!

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

    Thank you so much John...I really love it."My best wishes to you and your family'.It helps me alot and clearly understand your explanation.Could you please teach us how to customize orders by allowing customers to select any quantity they want, instead of limiting their selections and adding session key expire date?

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

      Welcome!

  • @eqfira
    @eqfira 6 หลายเดือนก่อน +2

    ❤This is not normal comment this is real comment I love it

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

      ha

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

    Hello John!
    When I add some product in to the cart and remove the first product I added to the cart the totals become 0 even if I have some products in the cart.
    And I have tried to check my code and your but don’t se any different things what can I do

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

      Put it away for a few days, don't look at it. Then after a few days compare your code to mine and the error will jump right out at you. You're too close to it right now to see your mistake.

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

      @@Codemycom thank you John 🙏🏽

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

    My problem is TypeError can’t multiply sequence by non -int of type decimal.Decimal

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

      what did you do differently from the video?

    • @devderole
      @devderole 8 วันที่ผ่านมา

      for some reason i had the same problem but i solved doing this
      def cart_total(self):
      # Get product IDS
      product_ids = self.cart.keys()
      # Lookup those keys in our products database model
      products = Product.objects.filter(id__in=product_ids)
      # Get quantities
      quantities = self.cart
      # Start counting at 0
      total = Decimal('0.0') # Inicialize total como Decimal
      for key, value in quantities.items():
      # Convert key string into int so we can do math
      key = int(key)
      for product in products:
      if product.id == key:
      qty = Decimal(value) # Converta value para Decimal
      if product.is_sale:
      total += product.sale_price * qty
      else:
      total += product.price * qty
      return total

  • @MrNakul1988
    @MrNakul1988 27 วันที่ผ่านมา

    Any hints or suggestions on using this code which shows individual product total which eventually get added to the final total please ?

    • @Codemycom
      @Codemycom  26 วันที่ผ่านมา

      Of course we add the individual to the final total...

    • @MrNakul1988
      @MrNakul1988 25 วันที่ผ่านมา

      @@Codemycom Trying to implement this where we could display the individual product total which finally adds up to the final total... Any suggestions on the videos I could rewatch to implement this please ?

    • @Codemycom
      @Codemycom  24 วันที่ผ่านมา

      @@MrNakul1988 You have all that information on the page already...just do some basic math and output it.

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

    💙💙💙💚💚💚

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

      🙂