Sha256: f242d9a52ea31724d62368ca9af4c8bc26a6e5fa148368bd84f79d6d49608615

Contents?: true

Size: 1.06 KB

Versions: 47

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Spree
  # Mailing after events on a {Spree::Order}
  class OrderMailerSubscriber
    include Omnes::Subscriber

    handle :order_finalized,
           with: :send_confirmation_email,
           id: :spree_order_mailer_send_confirmation_email

    handle :reimbursement_reimbursed,
           with: :send_reimbursement_email,
           id: :spree_order_mailer_send_reimbursement_email

    # Sends confirmation email to the user
    #
    # @param event [Omnes::UnstructuredEvent]
    def send_confirmation_email(event)
      order = event[:order]
      unless order.confirmation_delivered?
        Spree::Config.order_mailer_class.confirm_email(order).deliver_later
        order.update_column(:confirmation_delivered, true)
      end
    end

    # Sends reimbursement email to the user
    #
    # @param event [Omnes::UnstructuredEvent]
    def send_reimbursement_email(event)
      reimbursement = event[:reimbursement]
      Spree::Config.reimbursement_mailer_class.reimbursement_email(reimbursement.id).deliver_later
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
solidus_core-4.4.2 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.4.1 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.4.0 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.3.4 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.2.4 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.1.5 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.3.3 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.3.2 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.1.4 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.3.1 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.3.0 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.2.3 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.1.3 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.0.4 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-3.4.6 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.0.3 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.1.2 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.2.2 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-3.4.5 app/subscribers/spree/order_mailer_subscriber.rb
solidus_core-4.2.1 app/subscribers/spree/order_mailer_subscriber.rb