Skip to content

Commit

Permalink
add bcc fields to stores
Browse files Browse the repository at this point in the history
  • Loading branch information
afdev82 committed Oct 12, 2018
1 parent 679ef79 commit eaf72fe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions backend/app/views/spree/admin/stores/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
<%= f.field_container :name do %>
<%= f.label :name, class: 'required' %>
<%= f.text_field :name, required: true, class: 'fullwidth' %>
Expand Down Expand Up @@ -40,6 +41,12 @@
<%= f.error_message_on :mail_from_address %>
<% end %>

<%= f.field_container :bcc_addresses do %>
<%= f.label :bcc_addresses, Spree.t(:send_order_mails_in_bcc_to) %><br />
<%= f.text_field :bcc_addresses, class: 'fullwidth' %>
<%= error_message_on :bcc_addresses %>
<% end %>

<%= f.field_container :default_currency do %>
<%= f.label :default_currency %>
<%= f.select :default_currency,
Expand Down
4 changes: 4 additions & 0 deletions core/app/mailers/spree/base_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ def from_address(store)
store.mail_from_address
end

def bcc_addresses(store)
store.bcc_addresses
end

def money(amount, currency = Spree::Config[:currency])
Spree::Money.new(amount, currency: currency).to_s
end
Expand Down
2 changes: 1 addition & 1 deletion core/app/mailers/spree/order_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def confirm_email(order, resend = false)
@store = @order.store
subject = build_subject(Spree.t('order_mailer.confirm_email.subject'), resend)

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

def cancel_email(order, resend = false)
Expand Down
1 change: 1 addition & 0 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,7 @@ en:
send_copy_of_all_mails_to: Send Copy of All Mails To
send_mailer: Send Mailer
send_mails_as: Send Mails As
send_order_mails_in_bcc_to: Send confirmation order emails in BCC to
server: Server
server_error: The server returned an error
settings: Settings
Expand Down
5 changes: 5 additions & 0 deletions core/db/migrate/20180124142140_add_mail_bcc_addresses.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMailBccAddresses < ActiveRecord::Migration[5.1]
def change
add_column :spree_stores, :bcc_addresses, :string
end
end

0 comments on commit eaf72fe

Please sign in to comment.