Files
openfoodnetwork/app/mailers/subscription_mailer.rb
Luis Ramos e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00

65 lines
1.6 KiB
Ruby

# frozen_string_literal: true
class SubscriptionMailer < Spree::BaseMailer
helper 'checkout'
helper MailerHelper
helper ShopMailHelper
helper OrderHelper
helper Spree::PaymentMethodsHelper
include I18nHelper
def confirmation_email(order)
@type = 'confirmation'
@order = order
send_mail(order)
end
def empty_email(order, changes)
@type = 'empty'
@changes = changes
@order = order
send_mail(order)
end
def placement_email(order, changes)
@type = 'placement'
@changes = changes
@order = order
send_mail(order)
end
def failed_payment_email(order)
@order = order
send_mail(order)
end
def placement_summary_email(summary)
@shop = Enterprise.find(summary.shop_id)
@summary = summary
mail(to: @shop.contact.email,
from: from_address,
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,
from: from_address,
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,
from: from_address,
subject: subject,
reply_to: order.distributor.contact.email)
end
end
end