effective_orders 4.2.6 → 4.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_orders/providers/stripe.js.coffee +1 -1
- data/app/models/effective/order.rb +20 -15
- data/app/views/effective/orders/_checkout_step1.html.haml +1 -31
- data/app/views/effective/orders/_fields.html.haml +34 -0
- data/lib/effective_orders.rb +1 -1
- data/lib/effective_orders/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0bd383b484e3db946b0a7bb199f7afb8d7d8600019dcfad46b00bf6ddb3d798
|
4
|
+
data.tar.gz: 16db4fd12e60d5995ec3dbc9003a720dacc8e9c95b761c622ac7c7db294ea77b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19022b230c19a97bc5c1c9a203df1407c86be04b802f01b157929ba6204e8bf60ba9dd3967e32c992fa95a6bbf75aa30ac8781b79fb789f4b2dd37117b002541
|
7
|
+
data.tar.gz: 2808d79b39ecae2b23bf2fd17cc9ed36085f11103d8d217eba454fa1508207d81331c4241a25e8a92c03ba604a18f93197028d9e7adad74d018be7a8d2fabd48
|
@@ -16,7 +16,7 @@ $(document).on 'click', "#effective-orders-new-charge-form form [type='submit']"
|
|
16
16
|
$form = obj.find('form').first()
|
17
17
|
stripe = obj.data('stripe')
|
18
18
|
|
19
|
-
|
19
|
+
EffectiveForm.submitting($form)
|
20
20
|
|
21
21
|
stripeCheckoutHandler(stripe.key, $form).open
|
22
22
|
image: stripe.image
|
@@ -21,6 +21,7 @@ module Effective
|
|
21
21
|
)
|
22
22
|
|
23
23
|
attr_accessor :terms_and_conditions # Yes, I agree to the terms and conditions
|
24
|
+
attr_accessor :confirmed_checkout # Set on the Checkout Step 1
|
24
25
|
|
25
26
|
# Settings in the /admin action forms
|
26
27
|
attr_accessor :send_payment_request_to_buyer # Set by Admin::Orders#new. Should the payment request email be sent after creating an order?
|
@@ -61,6 +62,10 @@ module Effective
|
|
61
62
|
before_validation { assign_billing_name }
|
62
63
|
before_validation { assign_last_address }
|
63
64
|
|
65
|
+
before_validation(if: -> { confirmed_checkout }) do
|
66
|
+
self.state = EffectiveOrders::CONFIRMED if pending?
|
67
|
+
end
|
68
|
+
|
64
69
|
# Order validations
|
65
70
|
validates :user_id, presence: true
|
66
71
|
validates :order_items, presence: { message: 'No items are present. Please add additional items.' }
|
@@ -75,41 +80,41 @@ module Effective
|
|
75
80
|
end
|
76
81
|
|
77
82
|
# User validations -- An admin skips these when working in the admin/ namespace
|
78
|
-
with_options unless: -> { pending? || skip_buyer_validations? } do
|
79
|
-
|
80
|
-
|
83
|
+
with_options unless: -> { pending? || skip_buyer_validations? } do
|
84
|
+
validates :tax_rate, presence: { message: "can't be determined based on billing address" }
|
85
|
+
validates :tax, presence: true
|
81
86
|
|
82
87
|
unless EffectiveOrders.skip_user_validation
|
83
|
-
|
84
|
-
|
88
|
+
validates :billing_name, presence: true
|
89
|
+
validates :user, associated: true
|
85
90
|
end
|
86
91
|
|
87
92
|
if EffectiveOrders.billing_address
|
88
|
-
|
93
|
+
validates :billing_address, presence: true
|
89
94
|
end
|
90
95
|
|
91
96
|
if EffectiveOrders.shipping_address
|
92
|
-
|
97
|
+
validates :shipping_address, presence: true
|
93
98
|
end
|
94
99
|
|
95
100
|
if EffectiveOrders.collect_note_required
|
96
|
-
|
101
|
+
validates :note, presence: true
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
100
|
-
with_options if: -> { confirmed? && !skip_buyer_validations? } do
|
105
|
+
with_options if: -> { confirmed? && !skip_buyer_validations? } do
|
101
106
|
if EffectiveOrders.terms_and_conditions
|
102
|
-
|
107
|
+
validates :terms_and_conditions, presence: true
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
106
111
|
# When Purchased
|
107
|
-
with_options if: -> { purchased? } do
|
108
|
-
|
109
|
-
|
112
|
+
with_options if: -> { purchased? } do
|
113
|
+
validates :purchased_at, presence: true
|
114
|
+
validates :payment, presence: true
|
110
115
|
|
111
|
-
|
112
|
-
|
116
|
+
validates :payment_provider, presence: true, inclusion: { in: EffectiveOrders.payment_providers }
|
117
|
+
validates :payment_card, presence: true
|
113
118
|
end
|
114
119
|
|
115
120
|
scope :deep, -> { includes(:user, order_items: :purchasable) }
|
@@ -1,34 +1,4 @@
|
|
1
1
|
.effective-order
|
2
2
|
= effective_form_with(model: order, url: checkout_step1_form_url(order, namespace)) do |f|
|
3
|
-
= render
|
4
|
-
= render partial: 'effective/orders/order_items', locals: { order: order }
|
5
|
-
|
6
|
-
- if current_cart.present?
|
7
|
-
.effective-order-change-items
|
8
|
-
= link_to 'Change Items', effective_orders.cart_path, rel: :nofollow, class: 'btn btn-secondary'
|
9
|
-
|
10
|
-
- if EffectiveOrders.collect_user_fields.present? && f.object.user.present?
|
11
|
-
= render partial: 'effective/orders/order_user_fields', locals: { form: f, user: f.object.user }
|
12
|
-
|
13
|
-
- num_addresses = [EffectiveOrders.billing_address, EffectiveOrders.shipping_address].count(true)
|
14
|
-
|
15
|
-
- if num_addresses > 0
|
16
|
-
.effective-order-addresses
|
17
|
-
.row
|
18
|
-
- if EffectiveOrders.billing_address
|
19
|
-
%div{class: "col-md-#{12 / num_addresses}"}
|
20
|
-
%h2 Billing Address
|
21
|
-
= effective_address_fields(f, :billing_address)
|
22
|
-
|
23
|
-
- if EffectiveOrders.shipping_address
|
24
|
-
%div{class: "col-md-#{12 / num_addresses}"}
|
25
|
-
%h2 Shipping Address
|
26
|
-
= effective_address_fields(f, :shipping_address)
|
27
|
-
|
28
|
-
- if EffectiveOrders.collect_note
|
29
|
-
= render partial: 'effective/orders/order_note_fields', locals: { form: f }
|
30
|
-
|
31
|
-
- if EffectiveOrders.terms_and_conditions
|
32
|
-
= render partial: 'effective/orders/order_terms_and_conditions_fields', locals: { form: f }
|
33
|
-
|
3
|
+
= render('effective/orders/fields', order: order, form: f)
|
34
4
|
= f.submit 'Proceed to Checkout'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
- form ||= local_assigns[:form] || local_assigns[:f]
|
2
|
+
|
3
|
+
= render 'effective/orders/order_notes', order: form.object
|
4
|
+
= render 'effective/orders/order_items', order: form.object
|
5
|
+
|
6
|
+
= form.hidden_field :confirmed_checkout, value: true
|
7
|
+
|
8
|
+
- if current_cart.present?
|
9
|
+
.effective-order-change-items
|
10
|
+
= link_to 'Change Items', effective_orders.cart_path, rel: :nofollow, class: 'btn btn-secondary'
|
11
|
+
|
12
|
+
- if EffectiveOrders.collect_user_fields.present? && form.object.user.present?
|
13
|
+
= render 'effective/orders/order_user_fields', form: form, user: form.object.user
|
14
|
+
|
15
|
+
- num_addresses = [EffectiveOrders.billing_address, EffectiveOrders.shipping_address].count(true)
|
16
|
+
|
17
|
+
- if num_addresses > 0
|
18
|
+
.effective-order-addresses
|
19
|
+
.row
|
20
|
+
- if EffectiveOrders.billing_address
|
21
|
+
%div{class: "col-md-#{12 / num_addresses}"}
|
22
|
+
%h2 Billing Address
|
23
|
+
= effective_address_fields(form, :billing_address)
|
24
|
+
|
25
|
+
- if EffectiveOrders.shipping_address
|
26
|
+
%div{class: "col-md-#{12 / num_addresses}"}
|
27
|
+
%h2 Shipping Address
|
28
|
+
= effective_address_fields(form, :shipping_address)
|
29
|
+
|
30
|
+
- if EffectiveOrders.collect_note
|
31
|
+
= render 'effective/orders/order_note_fields', form: form
|
32
|
+
|
33
|
+
- if EffectiveOrders.terms_and_conditions
|
34
|
+
= render 'effective/orders/order_terms_and_conditions_fields', form: form
|
data/lib/effective_orders.rb
CHANGED
@@ -89,7 +89,7 @@ module EffectiveOrders
|
|
89
89
|
|
90
90
|
def self.permitted_params
|
91
91
|
[
|
92
|
-
:note, :terms_and_conditions,
|
92
|
+
:note, :terms_and_conditions, :confirmed_checkout,
|
93
93
|
billing_address: EffectiveAddresses.permitted_params,
|
94
94
|
shipping_address: EffectiveAddresses.permitted_params,
|
95
95
|
user_attributes: (EffectiveOrders.collect_user_fields || []),
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03
|
11
|
+
date: 2020-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- app/views/effective/orders/_checkout_actions.html.haml
|
191
191
|
- app/views/effective/orders/_checkout_step1.html.haml
|
192
192
|
- app/views/effective/orders/_checkout_step2.html.haml
|
193
|
+
- app/views/effective/orders/_fields.html.haml
|
193
194
|
- app/views/effective/orders/_order.html.haml
|
194
195
|
- app/views/effective/orders/_order_actions.html.haml
|
195
196
|
- app/views/effective/orders/_order_footer.html.haml
|