Class: Spree::CartonShippedMailerSubscriber

Inherits:
Object
  • Object
show all
Includes:
Omnes::Subscriber
Defined in:
app/subscribers/spree/carton_shipped_mailer_subscriber.rb

Overview

Mailing after Carton is created.

Instance Method Summary collapse

Instance Method Details

#send_carton_shipped_emails(event) ⇒ Object

Sends carton shipped emails to users.

Parameters:

  • event (Omnes::UnstructuredEvent)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/subscribers/spree/carton_shipped_mailer_subscriber.rb', line 15

def send_carton_shipped_emails(event)
  carton = event[:carton]

  return if carton.suppress_email

  # Do not send emails for unfulfillable cartons (i.e. for digital goods).
  return unless carton.stock_location.fulfillable?

  carton.orders.each do |order|
    Spree::Config.carton_shipped_email_class
      .shipped_email(order:, carton:)
      .deliver_later
  end
end