Rebuild the Checkout class, no discounts yet

Checkout now stores its items using a quantity and a link back to the
original product instance. It has a reference to the store to make sure
that product IDs added are valid
This commit is contained in:
David Underwood
2026-07-21 10:27:33 -04:00
parent e570783935
commit 882c18b5e6
4 changed files with 91 additions and 58 deletions
+22
View File
@@ -0,0 +1,22 @@
class ProductInCheckout
def initialize(product:, quantity: 0)
@product = product
@quantity = quantity
end
def product_id
@product.id
end
def quantity
@quantity
end
def add_quantity(quantity)
@quantity += quantity
end
def total
@product.price * quantity
end
end