Sha256: d73c9a44dfa3ba29962f099f81ea22410934ea5a29549d488a5f7ab9870188d5

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

module Spree
  class OrderMailer < BaseMailer
    def confirm_email(order, resend = false)
      @order = find_order(order)
      @store = @order.store
      subject = build_subject(Spree.t('order_mailer.confirm_email.subject'), resend)

      mail(to: @order.email, from: from_address(@store), subject: subject)
    end

    def cancel_email(order, resend = false)
      @order = find_order(order)
      @store = @order.store
      subject = build_subject(Spree.t('order_mailer.cancel_email.subject'), resend)

      mail(to: @order.email, from: from_address(@store), subject: subject)
    end

    def inventory_cancellation_email(order, inventory_units, resend = false)
      @order, @inventory_units = find_order(order), inventory_units
      @store = @order.store
      subject = build_subject(Spree.t('order_mailer.inventory_cancellation.subject'), resend)

      mail(to: @order.email, from: from_address(@store), subject: subject)
    end

    private

    def find_order(order)
      if order.respond_to?(:id)
        order
      else
        ActiveSupport::Deprecation.warn("Calling OrderMailer with an id is deprecated. Pass the Spree::Order object instead.")
        Spree::Order.find(order)
      end
    end

    def build_subject(subject_text, resend)
      resend_text = (resend ? "[#{Spree.t(:resend).upcase}] " : '')
      "#{resend_text}#{Spree::Store.current.name} #{subject_text} ##{@order.number}"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_core-1.3.2 app/mailers/spree/order_mailer.rb
solidus_core-1.3.1 app/mailers/spree/order_mailer.rb
solidus_core-1.3.0 app/mailers/spree/order_mailer.rb
solidus_core-1.3.0.rc2 app/mailers/spree/order_mailer.rb
solidus_core-1.3.0.rc1 app/mailers/spree/order_mailer.rb
solidus_core-1.3.0.beta1 app/mailers/spree/order_mailer.rb