effective_orders 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/effective/orders_controller.rb +26 -0
- data/app/helpers/effective_orders_helper.rb +3 -0
- data/app/views/effective/orders/_checkout_step1.html.haml +3 -0
- data/app/views/effective/orders/_order_shipping.html.haml +4 -5
- data/app/views/effective/orders/pretend/_form.html.haml +3 -1
- data/lib/effective_orders/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c63ea13e03cd733ba8ee14f51ab78df6fbbfc25f4b6546d946b20facfa15aaa6
|
4
|
+
data.tar.gz: 1a5c4d4ca4ce70f3c20c8984cfe2063104908c292f7b37a8ebb0e209c2e60e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e66345b50629cd33f2e046d910d3d5cf10f735d730e3810c919cfe8fae0fff6731ff85370d2184104898441d9bcc58e7d0bbbdbe06194182e58e70e4d92636d
|
7
|
+
data.tar.gz: 7f6a851d15695bea583d3ba315e2df215df31be66e1bf3d8d46766ffbf500e111bce198be45b4b947373fac3776d3a1c7dfe1827c60b36efd3bba38c5293d5d9
|
@@ -56,6 +56,7 @@ module Effective
|
|
56
56
|
Effective::Order.transaction do
|
57
57
|
begin
|
58
58
|
@order.save!
|
59
|
+
set_redirect_cookie!
|
59
60
|
redirect_to(effective_orders.order_path(@order)) and return
|
60
61
|
rescue => e
|
61
62
|
raise ActiveRecord::Rollback
|
@@ -80,6 +81,8 @@ module Effective
|
|
80
81
|
Effective::Order.transaction do
|
81
82
|
begin
|
82
83
|
@order.save!
|
84
|
+
set_redirect_cookie!
|
85
|
+
|
83
86
|
redirect_to(effective_orders.order_path(@order)) and return
|
84
87
|
rescue => e
|
85
88
|
raise ActiveRecord::Rollback
|
@@ -125,6 +128,8 @@ module Effective
|
|
125
128
|
Effective::Order.purchased_by(current_user).first
|
126
129
|
end
|
127
130
|
|
131
|
+
clear_redirect_cookie!
|
132
|
+
|
128
133
|
if @order.blank?
|
129
134
|
redirect_to(effective_orders.my_purchases_orders_path) and return
|
130
135
|
end
|
@@ -138,6 +143,8 @@ module Effective
|
|
138
143
|
@order = Effective::Order.find(params[:id])
|
139
144
|
EffectiveOrders.authorize!(self, :show, @order)
|
140
145
|
|
146
|
+
clear_redirect_cookie!
|
147
|
+
|
141
148
|
redirect_to(effective_orders.order_path(@order)) unless @order.declined?
|
142
149
|
end
|
143
150
|
|
@@ -180,6 +187,25 @@ module Effective
|
|
180
187
|
|
181
188
|
private
|
182
189
|
|
190
|
+
def set_redirect_cookie!
|
191
|
+
return unless @order.present?
|
192
|
+
|
193
|
+
if params[:purchased_url]
|
194
|
+
session["effective_orders_#{@order.id}_purchased_url"] = params[:purchased_url]
|
195
|
+
end
|
196
|
+
|
197
|
+
if params[:declined_url]
|
198
|
+
session["effective_orders_#{@order.id}_declined_url"] = params[:declined_url]
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def clear_redirect_cookie!
|
203
|
+
return unless @order.present?
|
204
|
+
|
205
|
+
session["effective_orders_#{@order.id}_purchased_url"] = nil
|
206
|
+
session["effective_orders_#{@order.id}_declined_url"] = nil
|
207
|
+
end
|
208
|
+
|
183
209
|
# StrongParameters
|
184
210
|
def checkout_params
|
185
211
|
params.require(:effective_order).permit(EffectiveOrders.permitted_params)
|
@@ -101,6 +101,9 @@ module EffectiveOrdersHelper
|
|
101
101
|
def render_checkout_step2(order, namespace: nil, purchased_url: nil, declined_url: nil)
|
102
102
|
raise 'unable to checkout an order without a user' unless order && order.user
|
103
103
|
|
104
|
+
purchased_url ||= session["effective_orders_#{order.id}_purchased_url"]
|
105
|
+
declined_url ||= session["effective_orders_#{order.id}_declined_url"]
|
106
|
+
|
104
107
|
locals = { order: order, purchased_url: purchased_url, declined_url: declined_url, namespace: namespace }
|
105
108
|
|
106
109
|
if order.new_record? || !order.valid?
|
@@ -1,5 +1,8 @@
|
|
1
1
|
.effective-order
|
2
2
|
= simple_form_for(order, (EffectiveOrders.simple_form_options || {}).merge(url: checkout_step1_form_url(order, namespace))) do |f|
|
3
|
+
= hidden_field_tag(:purchased_url, purchased_url) if defined?(:purchased_url)
|
4
|
+
= hidden_field_tag(:declined_url, declined_url) if defined?(:declined_url)
|
5
|
+
|
3
6
|
= render partial: 'effective/orders/order_items', locals: { order: order, form: f }
|
4
7
|
|
5
8
|
- unless f.object.pending? || (current_cart && current_cart.blank?)
|
@@ -9,14 +9,13 @@
|
|
9
9
|
%tbody
|
10
10
|
%tr
|
11
11
|
%td
|
12
|
+
- unless EffectiveOrders.use_address_full_name
|
13
|
+
= order.billing_name
|
14
|
+
%br
|
15
|
+
|
12
16
|
- if order.billing_address.present?
|
13
17
|
= render :partial => 'effective/addresses/address',
|
14
18
|
locals: {address: order.billing_address, email: order.user.email }
|
15
|
-
- else
|
16
|
-
= order.billing_name
|
17
|
-
%br
|
18
|
-
= mail_to(order.user.email)
|
19
|
-
%br
|
20
19
|
|
21
20
|
- if order.shipping_address.present?
|
22
21
|
%td
|
@@ -1,2 +1,4 @@
|
|
1
|
-
= form_tag(effective_orders.pretend_order_path(order
|
1
|
+
= form_tag(effective_orders.pretend_order_path(order), method: :post) do
|
2
|
+
= hidden_field_tag(:purchased_url, purchased_url)
|
3
|
+
= hidden_field_tag(:declined_url, declined_url)
|
2
4
|
= submit_tag order_checkout_label(:pretend), class: 'btn btn-primary', data: { disable_with: 'Continuing...' }
|