Files
openfoodnetwork/app/mailers/subscription_mailer.rb
drummer83 5ce7905a33 White labelling ALL customer facing emails
White labelling added for Order: cancellation email, Order: invoice email, Shipment: shipped email, Subscriptions: authorize payment email, Subscriptions: placement email, Subscriptions: empty order email, Subscriptions: failed payment email

White labelling existed already for Order: confirmation email, Subscriptions: order confirmation email
2025-12-29 12:18:54 +01:00

68 lines
1.8 KiB
Ruby

# frozen_string_literal: true
class SubscriptionMailer < ApplicationMailer
helper 'checkout'
helper MailerHelper
helper ShopMailHelper
helper OrderHelper
helper Spree::PaymentMethodsHelper
include I18nHelper
def confirmation_email(order)
@type = 'confirmation'
@order = order
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
send_mail(order)
end
def empty_email(order, changes)
@type = 'empty'
@changes = changes
@order = order
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
send_mail(order)
end
def placement_email(order, changes)
@type = 'placement'
@changes = changes
@order = order
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
send_mail(order)
end
def failed_payment_email(order)
@order = order
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
send_mail(order)
end
def placement_summary_email(summary)
@shop = Enterprise.find(summary.shop_id)
@summary = summary
mail(to: @shop.contact.email,
subject: "#{Spree::Config[:site_name]} " \
"#{t('subscription_mailer.placement_summary_email.subject')}")
end
def confirmation_summary_email(summary)
@shop = Enterprise.find(summary.shop_id)
@summary = summary
mail(to: @shop.contact.email,
subject: "#{Spree::Config[:site_name]} " \
"#{t('subscription_mailer.confirmation_summary_email.subject')}")
end
private
def send_mail(order)
I18n.with_locale valid_locale(order.user) do
confirm_email_subject = t('spree.order_mailer.confirm_email.subject')
subject = "#{Spree::Config[:site_name]} #{confirm_email_subject} ##{order.number}"
mail(to: order.email,
subject:,
reply_to: order.distributor.contact.email)
end
end
end