effective_orders 5.2.0 → 5.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/admin/effective_orders_datatable.rb +3 -1
- data/app/datatables/effective_orders_datatable.rb +2 -1
- data/app/models/concerns/acts_as_purchasable_parent.rb +34 -0
- data/app/models/effective/order.rb +17 -7
- data/app/views/effective/orders/_checkout_step2.html.haml +2 -1
- data/lib/effective_orders/engine.rb +1 -0
- data/lib/effective_orders/version.rb +1 -1
- data/lib/effective_orders.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: b05f84b1f3b3cda586c6cb1721b3f7f2b5df015c16b03cea26842dec69e079d0
|
4
|
+
data.tar.gz: 7064dc16608557f87e3189737c6df2ec54a39fccdf640cb9de40c03a0805011d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2701472dd97d9fa7e8c02729abe8b403e59279ba551628efaebf35b9f0b4a72e5574a8620ee11b94b033f996f459ddd215596e9ed119b07d25f015759457eaf
|
7
|
+
data.tar.gz: e612099005a16265d1d3f4165de40bf23e55fbc36252f66310ef04fbc0e3a993c4fa7f72357134e5ab2850d4c78d032498054afa0c9c3ce80a4345ef29ce511a
|
@@ -93,7 +93,9 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
|
|
93
93
|
end
|
94
94
|
|
95
95
|
if attributes[:user_id].present?
|
96
|
-
|
96
|
+
user_klass = (attributes[:user_type].safe_constantize || current_user.class)
|
97
|
+
user = user_klass.find(attributes[:user_id])
|
98
|
+
|
97
99
|
scope = scope.where(user: user)
|
98
100
|
end
|
99
101
|
|
@@ -62,7 +62,8 @@ class EffectiveOrdersDatatable < Effective::Datatable
|
|
62
62
|
end
|
63
63
|
|
64
64
|
collection do
|
65
|
-
|
65
|
+
user_klass = (attributes[:user_type].safe_constantize || current_user.class)
|
66
|
+
user = user_klass.find(attributes[:user_id])
|
66
67
|
|
67
68
|
scope = Effective::Order.all.deep.where(user: user)
|
68
69
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Mostly for the callbacks
|
2
|
+
|
3
|
+
module ActsAsPurchasableParent
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module Base
|
7
|
+
def acts_as_purchasable_parent(*options)
|
8
|
+
@acts_as_purchasable_parent = options || []
|
9
|
+
include ::ActsAsPurchasableParent
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def acts_as_purchasable_parent?; true; end
|
15
|
+
|
16
|
+
def before_purchase(&block)
|
17
|
+
send :define_method, :before_purchase do |order| self.instance_exec(order, &block) end
|
18
|
+
end
|
19
|
+
|
20
|
+
def after_purchase(&block)
|
21
|
+
send :define_method, :after_purchase do |order| self.instance_exec(order, &block) end
|
22
|
+
end
|
23
|
+
|
24
|
+
def after_decline(&block)
|
25
|
+
send :define_method, :after_decline do |order| self.instance_exec(order, &block) end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
included do
|
30
|
+
has_many :orders, -> { order(:id) }, as: :parent, class_name: 'Effective::Order', dependent: :nullify
|
31
|
+
accepts_nested_attributes_for :orders
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -459,13 +459,16 @@ module Effective
|
|
459
459
|
self.payment = payment_to_h(payment) if self.payment.blank?
|
460
460
|
|
461
461
|
begin
|
462
|
-
|
462
|
+
EffectiveResources.transaction do
|
463
463
|
run_purchasable_callbacks(:before_purchase)
|
464
|
+
|
464
465
|
save!
|
465
466
|
update_purchasables_purchased_order!
|
467
|
+
|
468
|
+
run_purchasable_callbacks(:after_purchase)
|
466
469
|
end
|
467
470
|
rescue => e
|
468
|
-
|
471
|
+
EffectiveResources.transaction do
|
469
472
|
save!(validate: false)
|
470
473
|
update_purchasables_purchased_order!
|
471
474
|
end
|
@@ -473,7 +476,6 @@ module Effective
|
|
473
476
|
raise(e)
|
474
477
|
end
|
475
478
|
|
476
|
-
run_purchasable_callbacks(:after_purchase)
|
477
479
|
send_order_receipts! if email
|
478
480
|
|
479
481
|
true
|
@@ -506,9 +508,11 @@ module Effective
|
|
506
508
|
skip_buyer_validations: true
|
507
509
|
)
|
508
510
|
|
509
|
-
|
511
|
+
EffectiveResources.transaction do
|
510
512
|
begin
|
513
|
+
run_purchasable_callbacks(:before_decline)
|
511
514
|
save!(validate: validate)
|
515
|
+
run_purchasable_callbacks(:after_decline)
|
512
516
|
rescue => e
|
513
517
|
self.state = state_was
|
514
518
|
|
@@ -519,8 +523,6 @@ module Effective
|
|
519
523
|
|
520
524
|
raise "Failed to decline order: #{error || errors.full_messages.to_sentence}" unless error.nil?
|
521
525
|
|
522
|
-
run_purchasable_callbacks(:after_decline)
|
523
|
-
|
524
526
|
true
|
525
527
|
end
|
526
528
|
|
@@ -637,7 +639,15 @@ module Effective
|
|
637
639
|
end
|
638
640
|
|
639
641
|
def run_purchasable_callbacks(name)
|
640
|
-
order_items.
|
642
|
+
order_items.select { |item| item.purchasable.respond_to?(name) }.each do |item|
|
643
|
+
EffectiveResources.transaction(item) { item.purchasable.public_send(name, self, item) }
|
644
|
+
end
|
645
|
+
|
646
|
+
if parent.respond_to?(name)
|
647
|
+
EffectiveResources.transaction(parent) { parent.public_send(name, self) }
|
648
|
+
end
|
649
|
+
|
650
|
+
true
|
641
651
|
end
|
642
652
|
|
643
653
|
def send_email(email, *args)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
= render partial: 'effective/orders/order', locals: { order: order }
|
2
2
|
|
3
|
-
- if
|
3
|
+
- # Show this if I'm on the effective orders checkout screen. But not on a rendered order.
|
4
|
+
- if order.persisted? && order.user == current_user && request.path.to_s.start_with?(effective_orders.order_path(order))
|
4
5
|
.effective-order-change-items
|
5
6
|
= link_to 'Change Addresses', effective_orders.edit_order_path(order), rel: :nofollow, class: 'btn btn-secondary'
|
6
7
|
|
@@ -6,6 +6,7 @@ module EffectiveOrders
|
|
6
6
|
initializer 'effective_orders.active_record' do |app|
|
7
7
|
ActiveSupport.on_load :active_record do
|
8
8
|
ActiveRecord::Base.extend(ActsAsPurchasable::Base)
|
9
|
+
ActiveRecord::Base.extend(ActsAsPurchasableParent::Base)
|
9
10
|
ActiveRecord::Base.extend(ActsAsSubscribable::Base)
|
10
11
|
ActiveRecord::Base.extend(ActsAsSubscribableBuyer::Base)
|
11
12
|
end
|
data/lib/effective_orders.rb
CHANGED
@@ -116,7 +116,7 @@ module EffectiveOrders
|
|
116
116
|
|
117
117
|
# The Effective::Order.payment_provider value must be in this collection
|
118
118
|
def self.payment_providers
|
119
|
-
|
119
|
+
[
|
120
120
|
('cheque' if cheque?),
|
121
121
|
('credit card' if mark_as_paid?),
|
122
122
|
('free' if free?),
|
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: 5.2.
|
4
|
+
version: 5.2.4
|
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: 2021-
|
11
|
+
date: 2021-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -215,6 +215,7 @@ files:
|
|
215
215
|
- app/helpers/effective_subscriptions_helper.rb
|
216
216
|
- app/mailers/effective/orders_mailer.rb
|
217
217
|
- app/models/concerns/acts_as_purchasable.rb
|
218
|
+
- app/models/concerns/acts_as_purchasable_parent.rb
|
218
219
|
- app/models/concerns/acts_as_subscribable.rb
|
219
220
|
- app/models/concerns/acts_as_subscribable_buyer.rb
|
220
221
|
- app/models/effective/cart.rb
|