shop_bunny 0.7.4.1 → 0.7.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,11 @@ module ShopBunny
11
11
  end
12
12
 
13
13
  def add_item
14
- quantity = params[:quantity].to_i || 1
14
+ if !params[:quantity].blank?
15
+ quantity = params[:quantity].to_i
16
+ else
17
+ quantity = 1
18
+ end
15
19
  @cart.add_item(@item, :quantity => quantity) if @item
16
20
  respond_with @cart do |format|
17
21
  format.html { redirect_to :action => :show }
@@ -30,8 +30,7 @@ module ShopBunny
30
30
  self.cart_items.inject(0) {|sum,e| sum += e.quantity*e.item.price}
31
31
  end
32
32
 
33
- # Calculates the total sum and applies the coupons discount!
34
- def total
33
+ def items_with_coupons
35
34
  sum = item_sum
36
35
 
37
36
  absolute_discount = coupons.sum(:discount_credit)
@@ -39,10 +38,12 @@ module ShopBunny
39
38
 
40
39
  sum -= absolute_discount
41
40
  sum *= relative_discount
42
-
43
- sum += shipping_costs
44
-
45
- [0, sum].max
41
+ end
42
+
43
+ # Calculates the total sum and applies the coupons discount!
44
+ def total
45
+
46
+ [0, items_with_coupons + shipping_costs].max
46
47
  end
47
48
 
48
49
  #increases the quantity of an article. creates a new one if it doesn't exist
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shop_bunny
3
3
  version: !ruby/object:Gem::Version
4
- hash: 101
4
+ hash: 99
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
9
  - 4
10
- - 1
11
- version: 0.7.4.1
10
+ - 2
11
+ version: 0.7.4.2
12
12
  platform: ruby
13
13
  authors:
14
14
  - kopfmaschine.com
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-12 00:00:00 +02:00
19
+ date: 2010-10-14 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies: []
22
22