Iteration 2: Creating a Smarter Cart

Learn to improve the functionality of an existing cart.

Introducing some useful methods for cart

Now we need a smart add_product() method in our Cart that checks if our list of items already includes the product we’re adding. If it does, it bumps the quantity, and if it doesn’t, it builds a new LineItem:

Get hands-on with 1400+ tech skills courses.