effective_orders 3.0.3 → 3.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79642ded2e176dd43991e456466b69110f2e36ca107a9d49b5e1267ab57ed580
4
- data.tar.gz: ec779c25f0fb3a8fcc55502105aa69e5a1d5586d2c4aedaef3bdbe4ad6194df3
3
+ metadata.gz: c63ea13e03cd733ba8ee14f51ab78df6fbbfc25f4b6546d946b20facfa15aaa6
4
+ data.tar.gz: 1a5c4d4ca4ce70f3c20c8984cfe2063104908c292f7b37a8ebb0e209c2e60e58
5
5
  SHA512:
6
- metadata.gz: 3fabbafe0cb9d7a3dc19e559f369ffc90a5a11fb3da6388bea46d6a9ea42255973f2b7467fadaa0b6e5d6752e56f788b422f9483612c25aeb581ff18d4b50a6f
7
- data.tar.gz: 2caec2a2464df534b68004d4050f7ab1d638c6c5c831b7a172dce582b64b61bf0c23fdd25dc517e316d3868e3d7973e6250735a91e4275f9d4180aacc1f607f7
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, purchased_url: purchased_url, declined_url: declined_url), method: :post) do
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...' }
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '3.0.3'.freeze
2
+ VERSION = '3.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect