Move backorder amendment out of order callback

Triggering it for each order is inefficient when we cancel them in bulk.
The callback doesn't allow us to optimise this.
This commit is contained in:
Maikel Linke
2024-12-06 10:05:37 +11:00
parent e76d6ad3df
commit 9ca1b48d2e
4 changed files with 3 additions and 2 deletions

View File

@@ -70,6 +70,7 @@ module Spree
@order.restock_items = params.fetch(:restock_items, "true") == "true"
if @order.public_send(event.to_s)
AmendBackorderJob.perform_later(@order) if event == "cancel"
flash[:success] = Spree.t(:order_updated)
else
flash[:error] = Spree.t(:cannot_perform_operation)

View File

@@ -142,8 +142,6 @@ module Spree
OrderMailer.cancel_email(id).deliver_later if send_cancellation_email
update(payment_state: updater.update_payment_state)
AmendBackorderJob.perform_later(self)
end
def after_resume

View File

@@ -15,6 +15,7 @@ module Orders
order.send_cancellation_email = @send_cancellation_email
order.restock_items = @restock_items
order.cancel
AmendBackorderJob.perform_later(order)
end
# rubocop:enable Rails/FindEach
end

View File

@@ -10,6 +10,7 @@ module Orders
return unless order.cancel
Spree::OrderMailer.cancel_email_for_shop(order).deliver_later
AmendBackorderJob.perform_later(order)
end
private