cirandas.net

ref: master

plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class ShoppingCartPlugin::Mailer < Noosfero::Plugin::MailerBase

  include ShoppingCartPlugin::CartHelper

  helper ShoppingCartPlugin::CartHelper

  attr_accessor :environment, :profile

  def customer_notification order, items
    domain = order.profile.hostname || order.profile.environment.default_hostname
    self.profile = order.profile
    self.environment = order.profile.environment
    @order = order
    @items = items

    mail(
      to:           @order.consumer_data[:email],
      from:         'no-reply@' + domain,
      reply_to:     @order.profile.cart_order_supplier_notification_recipients,
      subject:      _("[%s] Your buy request was performed successfully.") % @order.profile.short_name(nil),
      content_type: 'text/html'
    )
  end

  def supplier_notification order, items
    domain = order.profile.environment.default_hostname
    self.profile = order.profile
    self.environment = order.profile.environment
    @order = order
    @items = items

    mail(
      to:            @order.profile.cart_order_supplier_notification_recipients,
      from:          'no-reply@' + domain,
      reply_to:      @order.consumer_data[:email],
      subject:       _("[%s] You have a new buy request from %s.") % [order.profile.environment.name, @order.consumer_data[:name]],
      content_type:  'text/html'
    )
  end
end