Closed giugrilli closed 3 years ago
it looks like these two handlers are called twice
base.state_machine.after_transition to: :complete, do: :generate_order_commissions base.state_machine.after_transition to: :complete, do: :send_notification_mails_to_vendors
any hint?
Basically when the server gets started, it looks like (at least in my solution) the .prepended method inside SpreeMultiVendor::Spree::OrderDecorator gets called twice.
The state_machine has no check of duplicate methods, therefore it injects two callbacks for each ":send_notification_mails_to_vendors" and ":generate_order_commissions"
This is the reason why, when the state goes to :complete both methods are called twice!
Temporarely, as workaround, I'm forking and doing this inside SpreeMultiVendor::Spree::OrderDecorator
unless base.state_machine.callbacks.values.any?{|callback| callback.any?{|cb| cb.instance_variable_get(:@methods).include?(:generate_order_commissions)}} base.state_machine.after_transition to: :complete, do: :generate_order_commissions end
This is also happening in my environment. 🙋
I was wondering how other people were dealing with it.
I'd like to know, will it happen in a production environment?
Maybe it's hard to happen if config.cache_classes = true
.
Same for me. Any news?
When placing an order, the confirmation email is sent twice to the vendor