stall 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/stall/checkout/steps_controller.rb +10 -1
- data/app/helpers/stall/checkout_helper.rb +1 -1
- data/app/models/stall/models/product_list.rb +2 -1
- data/app/views/stall/carts/show.html.haml +1 -1
- data/lib/stall/cart_helper.rb +4 -2
- data/lib/stall/checkout/payment_checkout_step.rb +7 -0
- data/lib/stall/checkout/payment_return_checkout_step.rb +7 -0
- data/lib/stall/checkout/step.rb +12 -0
- data/lib/stall/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93101cd6c71bd164e54d7f7a96009894eaee815d
|
4
|
+
data.tar.gz: e9e552e25b8fa6a49ac0423cacac158b267585ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad0c5c29e895dcadf8aff1631374685f209ce73db2e6c28ff313648e33c67093dbb0fbef762d34abcaaf9b3eb4f015a6a151285b47f8327fb194c3e162f0dfa1
|
7
|
+
data.tar.gz: ad331dadf79752be6c13933ef96060aa07c4b7ae5ebbea33f42757d2160bfb10825d30c2f6dbe0092d91edb1df82abbb419bc8e55f3b5583274bd889a1b3e7ad
|
@@ -4,8 +4,8 @@ module Stall
|
|
4
4
|
include Stall::CheckoutHelper
|
5
5
|
|
6
6
|
before_action :load_cart
|
7
|
-
before_action :ensure_cart_checkoutable
|
8
7
|
before_action :load_step
|
8
|
+
before_action :ensure_cart_checkoutable
|
9
9
|
|
10
10
|
def show
|
11
11
|
@step.prepare
|
@@ -41,7 +41,16 @@ module Stall
|
|
41
41
|
@cart = current_cart
|
42
42
|
end
|
43
43
|
|
44
|
+
def find_cart(identifier, ensure_active_cart = true)
|
45
|
+
super(identifier, false)
|
46
|
+
end
|
47
|
+
|
44
48
|
def ensure_cart_checkoutable
|
49
|
+
unless @cart.active? || @step.allow_inactive_carts?
|
50
|
+
remove_cart_from_cookies(@cart.identifier)
|
51
|
+
@cart = @cart.class.new
|
52
|
+
end
|
53
|
+
|
45
54
|
unless @cart.checkoutable?
|
46
55
|
flash[:error] = t('stall.checkout.shared.not_checkoutable')
|
47
56
|
redirect_to request.referrer || root_path
|
@@ -59,5 +59,5 @@
|
|
59
59
|
%button.btn.btn-default{ type: 'submit', data: { :'cart-update-button' => true } }
|
60
60
|
= t('stall.carts.recap.update')
|
61
61
|
|
62
|
-
= link_to checkout_path(
|
62
|
+
= link_to checkout_path(current_cart.identifier), class: 'btn btn-primary' do
|
63
63
|
= t('stall.carts.recap.validate')
|
data/lib/stall/cart_helper.rb
CHANGED
@@ -46,9 +46,11 @@ module Stall
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
def find_cart(identifier)
|
49
|
+
def find_cart(identifier, ensure_active_cart = true)
|
50
50
|
if (cart_token = cookies.encrypted[cart_key(identifier)])
|
51
|
-
if (current_cart = ProductList.find_by_token(cart_token)) &&
|
51
|
+
if (current_cart = ProductList.find_by_token(cart_token)) &&
|
52
|
+
(!ensure_active_cart || current_cart.active?)
|
53
|
+
then
|
52
54
|
return current_cart
|
53
55
|
else
|
54
56
|
# Remove any cart that can't be fetched, either because it's already
|
@@ -4,6 +4,13 @@ module Stall
|
|
4
4
|
def process
|
5
5
|
return true if params[:succeeded]
|
6
6
|
end
|
7
|
+
|
8
|
+
# When we access this step after a payment to validate the step, the cart
|
9
|
+
# is "inactive", so we force processing the cart.
|
10
|
+
#
|
11
|
+
def allow_inactive_carts?
|
12
|
+
!!params[:succeeded]
|
13
|
+
end
|
7
14
|
end
|
8
15
|
end
|
9
16
|
end
|
@@ -6,6 +6,13 @@ module Stall
|
|
6
6
|
def prepare
|
7
7
|
remove_cart_from_cookies(cart.identifier)
|
8
8
|
end
|
9
|
+
|
10
|
+
# When we access this step, the cart is "inactive", since it is paid, so
|
11
|
+
# we force processing the cart.
|
12
|
+
#
|
13
|
+
def allow_inactive_carts?
|
14
|
+
true
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
data/lib/stall/checkout/step.rb
CHANGED
@@ -50,6 +50,18 @@ module Stall
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# Allows subclasses to override this value with `true` to allow paid carts
|
54
|
+
# to be processed by that step too.
|
55
|
+
#
|
56
|
+
# Returning false redirects the user telling him that his cart is empty
|
57
|
+
#
|
58
|
+
# By default, the `PaymentReturn` checkout step returns true, since it's
|
59
|
+
# always called after the cart is paid
|
60
|
+
#
|
61
|
+
def allow_inactive_carts?
|
62
|
+
false
|
63
|
+
end
|
64
|
+
|
53
65
|
# Abstracts the simple case of assigning the submitted parameters to the
|
54
66
|
# cart object, running the step validations and saving the cart
|
55
67
|
def save
|
data/lib/stall/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vala
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|