X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;ds=inline;f=app%2Fmodels%2Fcart.rb;h=bd51c383311d6a0a008208a3908955e330be963a;hb=c445da2b4dc5097fcfddf5e40d74c2965573fc1c;hp=0f1d52e731588dd79ac0bde3fe487761d93ad3be;hpb=c611b802645df9f0b490550d8c352fd24eb6ec5b;p=depot.git

diff --git a/app/models/cart.rb b/app/models/cart.rb
index 0f1d52e..bd51c38 100644
--- a/app/models/cart.rb
+++ b/app/models/cart.rb
@@ -10,12 +10,18 @@ class Cart
     if current_item
       current_item.increment_quantity
     else
-      @items << CartItem.new(product)
+      current_item = CartItem.new(product)
+      @items << current_item
     end
+    current_item
   end
   
   def total_price
     @items.sum {|item| item.price}
   end
   
+  def total_items
+    @items.sum {|item| item.quantity}
+  end
+  
 end