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 +8 -8
- data/app/controllers/caboose/cart_controller.rb +9 -4
- data/lib/caboose/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDExZjI0NmIzNDc3YmVhMzJiODJmZGJhMmY3OWNkNmI5OGZjZTZkNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmIyMWViMTNmM2E1NGY2OGY4NjEzOTZmMDAxMmJjOTllYWRjYWQ4NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTNiOTQyNTNkZWM5NzIyNzJmN2Q3ZDJiZjBkYmEyNDcxNDA1OTdlNGI1ZDZh
|
10
|
+
NGE0ZDI2NDhmMzI3ODMyZWYwN2Y3MWRjYTI4ODA3ZWU0YWM1ZTYyYzZhZDEw
|
11
|
+
YTc4OTFhMDczZTVhZjRkZDY3YmIzNjI1NWI4ODI5YTlkMWViN2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
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 =>
|
46
|
-
li = @order.line_items.find_by_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
|
data/lib/caboose/version.rb
CHANGED