From bcc9d447e1038632da5209bd6f55eb86957854b6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Mon, 17 Oct 2022 16:40:01 +0200 Subject: [PATCH] Create a reflex that handle re-send email confirmation to user --- app/reflexes/resend_confirmation_email_reflex.rb | 13 +++++++++++++ config/locales/en.yml | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 app/reflexes/resend_confirmation_email_reflex.rb diff --git a/app/reflexes/resend_confirmation_email_reflex.rb b/app/reflexes/resend_confirmation_email_reflex.rb new file mode 100644 index 0000000000..62c99619fd --- /dev/null +++ b/app/reflexes/resend_confirmation_email_reflex.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ResendConfirmationEmailReflex < ApplicationReflex + def confirm(order_ids) + Spree::Order.where(id: order_ids).find_each do |o| + Spree::OrderMailer.confirm_email_for_customer(o.id, true).deliver_later + end + + flash[:success] = I18n.t("admin.resend_confirmation_emails_feedback", count: order_ids.count) + cable_ready.dispatch_event(name: "modal:close") + morph "#flashes", render(partial: "shared/flashes", locals: { flashes: flash }) + end +end diff --git a/config/locales/en.yml b/config/locales/en.yml index 3016c015a4..ba026c13ae 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1566,6 +1566,10 @@ en: stripe_connect_settings: resource: Stripe Connect configuration + resend_confirmation_emails_feedback: + one: "Confirmation email sent for 1 order." + other: "Confirmation emails sent for %{count} orders." + # API # api: