caboose-cms 0.5.125 → 0.5.126

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjMxMTI2ZDVkYmZiYjMwOTUwMzM3OTgzM2M4NDIwZjhiNmMyNWM2OQ==
4
+ MDExZjI0NmIzNDc3YmVhMzJiODJmZGJhMmY3OWNkNmI5OGZjZTZkNQ==
5
5
  data.tar.gz: !binary |-
6
- YTgyNjNlYzllMDgyOTViNzlkYjcxN2Q0NzNlMGE5ZTQ3Zjk5ZTFhOA==
6
+ YmIyMWViMTNmM2E1NGY2OGY4NjEzOTZmMDAxMmJjOTllYWRjYWQ4NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzNmYTYyNDVkYzkwZmJkYzVmODhkMmZkZGNlMDM4YjJmNTVkYjY2Y2NiMTVi
10
- NzQyMTlhNDU3OTIyNWM5NWUxYmI5NDU2NTgwNWIwMGQxZjc5YjZhNTQzZmJj
11
- MTk5NDlkYmZhMTYwYmY2YzAxODcxODFmNDQ0ZDk1ODRkZTI2YTY=
9
+ OTNiOTQyNTNkZWM5NzIyNzJmN2Q3ZDJiZjBkYmEyNDcxNDA1OTdlNGI1ZDZh
10
+ NGE0ZDI2NDhmMzI3ODMyZWYwN2Y3MWRjYTI4ODA3ZWU0YWM1ZTYyYzZhZDEw
11
+ YTc4OTFhMDczZTVhZjRkZDY3YmIzNjI1NWI4ODI5YTlkMWViN2U=
12
12
  data.tar.gz: !binary |-
13
- YWY0YmI0YjQzNjI5NmE1NjAxZjg5YWIyYzZlOGM3ZDU4YTNlYzFhOGFkNGZi
14
- NmJiN2I4OWZkMTc5OTdjYmI1YWNjMTcwMjY4MzA0YmQ1MTg4NmNjMzY3MmJl
15
- MzhjYjE4ZDBhMGY5MjJjNTRmNGNjZGFmOTI0OGQ0NDBlM2QxZjQ=
13
+ ODZlNDlmNTRmNWYxMGM5OTkxNjcwNjkzOWU2YmRjMzEwZTRmOTNjYWQwYmZl
14
+ MmE3Nzc5ZGRhMjAzYzkwY2Y1MzczNDdiN2E4Y2FmY2FhMjc2ODkzNmQxNDlm
15
+ ZjZhNDFiYjA4MjJhNDM2ZTI4M2Q3M2MxYjRlYjRhNzY2Y2Q5NDQ=
@@ -38,18 +38,22 @@ module Caboose
38
38
  end
39
39
 
40
40
  # POST /cart
41
- def add
42
- variant_id = params[:variant_id]
41
+ def add
42
+ v = Variant.find(params[:variant_id])
43
43
  qty = params[:quantity] ? params[:quantity].to_i : 1
44
44
 
45
- if @order.line_items.exists?(:variant_id => variant_id)
46
- li = @order.line_items.find_by_variant_id(variant_id)
45
+ if @order.line_items.exists?(:variant_id => v.id)
46
+ li = @order.line_items.find_by_variant_id(v.id)
47
47
  li.quantity += qty
48
+ li.subtotal = li.unit_price * li.quantity
48
49
  else
50
+ unit_price = v.on_sale? ? v.sale_price : v.price
49
51
  li = LineItem.new(
50
52
  :order_id => @order.id,
51
53
  :variant_id => variant_id,
52
54
  :quantity => qty,
55
+ :unit_price => unit_price,
56
+ :subtotal => unit_price * qty,
53
57
  :status => 'pending'
54
58
  )
55
59
  end
@@ -64,6 +68,7 @@ module Caboose
64
68
  def update
65
69
  li = LineItem.find(params[:line_item_id])
66
70
  li.quantity = params[:quantity].to_i
71
+ li.subtotal = li.unit_price * li.quantity
67
72
  li.save
68
73
  li.destroy if li.quantity == 0
69
74
  @order.calculate_subtotal
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.125'
2
+ VERSION = '0.5.126'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.125
4
+ version: 0.5.126
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry