Sha256: 6263f60b63d3eb6b81eea4dd6100b4ecf559df846071a446321b06f745105fcf
Contents?: true
Size: 1.44 KB
Versions: 11
Compression:
Stored size: 1.44 KB
Contents
module Spree class BaseMailer < ActionMailer::Base helper Spree::MailHelper def current_store @current_store ||= @order&.store.presence || Spree::Dependencies.current_store_finder.constantize.new.execute end helper_method :current_store def from_address current_store.mail_from_address end def money(amount, currency = nil) currency ||= current_store.default_currency Spree::Money.new(amount, currency: currency).to_s end helper_method :money def frontend_available? Spree::Core::Engine.frontend_available? end helper_method :frontend_available? def mail(headers = {}, &block) ensure_default_action_mailer_url_host(headers[:store_url]) set_email_locale super if Spree::Config[:send_core_emails] end private # this ensures that ActionMailer::Base.default_url_options[:host] is always set # this is only a fail-safe solution if developer didn't set this in environment files # http://guides.rubyonrails.org/action_mailer_basics.html#generating-urls-in-action-mailer-views def ensure_default_action_mailer_url_host(store_url = nil) ActionMailer::Base.default_url_options ||= {} ActionMailer::Base.default_url_options[:host] ||= store_url || current_store.url end def set_email_locale locale = @order&.store&.default_locale || current_store&.default_locale I18n.locale = locale if locale.present? end end end
Version data entries
11 entries across 11 versions & 1 rubygems