Sha256: 67eda86e6616c02c843f9f4fa9cbf8e666c449089fe77a3c749cbf0743b4b41c
Contents?: true
Size: 1.51 KB
Versions: 21
Compression:
Stored size: 1.51 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 reply_to_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
21 entries across 21 versions & 1 rubygems