Sha256: 7b2d4a5396aad152454b5b01373a01cb1c4b060e706ef362ce841c8510b7e3a4

Contents?: true

Size: 1.48 KB

Versions: 62

Compression:

Stored size: 1.48 KB

Contents

module Workarea
  module Storefront
    class FulfillmentMailer < Storefront::ApplicationMailer
      include TransactionalMailer

      def shipped(order_id, tracking_number)
        order = Order.find(order_id)
        @order = Storefront::OrderViewModel.new(order)

        fulfillment = Fulfillment.find_or_initialize_by(id: order_id)
        package = fulfillment.find_package(tracking_number)
        @package = Storefront::PackageViewModel.new(package, order: @order)
        @recommendations = Storefront::EmailRecommendationsViewModel.wrap(order)

        mail(
          to: @order.email,
          subject: t(
            'workarea.storefront.email.order_shipped.subject',
            order_id: @order.id
          )
        )
      end

      def canceled(order_id, quantities)
        model = Order.find(order_id)
        @order = Storefront::OrderViewModel.new(model)
        @recommendations = Storefront::EmailRecommendationsViewModel.wrap(model)

        @cancellations = quantities # TODO: Remove in v4, no longer needed.
        @canceled_items ||= quantities.keys.map do |item_id|
          item = @order.items.detect { |i| i.id.to_s == item_id.to_s }
          next unless item.present?

          FulfillmentItemViewModel.new(item, quantity: quantities[item_id])
        end.compact

        mail(
          to: @order.email,
          subject: t(
            'workarea.storefront.email.order_cancellation.subject',
            order_id: @order.id
          )
        )
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.5.27 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.26 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.45 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.25 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.23 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.44 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.22 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.43 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.21 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.42 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.20 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.41 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.19 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.40 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.18 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.39 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.17 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.38 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.5.16 app/mailers/workarea/storefront/fulfillment_mailer.rb
workarea-storefront-3.4.37 app/mailers/workarea/storefront/fulfillment_mailer.rb