shop_bunny 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,9 @@ class CartItem < ActiveRecord::Base
10
10
  after_update :destroy_if_empty
11
11
  # TODO attr_accessible :quantity
12
12
 
13
+ def total_price
14
+ quantity * item.price
15
+ end
13
16
 
14
17
  private
15
18
 
data/app/models/coupon.rb CHANGED
@@ -5,7 +5,6 @@ class Coupon < ActiveRecord::Base
5
5
  validates_presence_of :code
6
6
  validates_uniqueness_of :code
7
7
  validates_presence_of :title
8
- attr_accessible
9
8
 
10
9
  # TODO Add self destruction when coupon has expired?
11
10
 
@@ -12,5 +12,9 @@ module ActionController
12
12
  session[:cart_id] = @cart.id
13
13
  end
14
14
  end
15
+
16
+ def clear_cart
17
+ session[:cart_id] = nil
18
+ end
15
19
  end
16
20
  end
@@ -1,7 +1,6 @@
1
1
  module ShopBunny
2
2
  module CartModule
3
3
 
4
-
5
4
  def self.included(clazz)
6
5
  clazz.send(:attr_accessor, :coupon_code)
7
6
  clazz.send(:has_many, :cart_items, :dependent => :destroy)
@@ -13,9 +12,6 @@ module ShopBunny
13
12
  clazz.send(:validate, :coupon_code_must_be_valid)
14
13
  end
15
14
 
16
-
17
-
18
-
19
15
  def items
20
16
  self.cart_items
21
17
  end
@@ -92,6 +88,11 @@ module ShopBunny
92
88
  ShopBunny.item_model_class_name.constantize
93
89
  end
94
90
 
91
+ # Check if the cart is empty
92
+ def empty?
93
+ cart_items.empty?
94
+ end
95
+
95
96
  # Make
96
97
  def as_json(options={})
97
98
  {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shop_bunny
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 3
10
- version: 0.7.3
9
+ - 4
10
+ version: 0.7.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - kopfmaschine.com
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-24 00:00:00 +02:00
18
+ date: 2010-09-29 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21