diff --git a/app/jobs/standing_order_placement_job.rb b/app/jobs/standing_order_placement_job.rb index 91ac2a87ec..681d0d5bc8 100644 --- a/app/jobs/standing_order_placement_job.rb +++ b/app/jobs/standing_order_placement_job.rb @@ -47,6 +47,6 @@ class StandingOrderPlacementJob end def send_placement_email(order, changes) - Spree::OrderMailer.standing_order_placement_email(order, changes).deliver + Spree::OrderMailer.standing_order_email(order, 'placement', changes).deliver end end diff --git a/app/mailers/spree/order_mailer_decorator.rb b/app/mailers/spree/order_mailer_decorator.rb index 821bd1db3b..afcb9de86e 100644 --- a/app/mailers/spree/order_mailer_decorator.rb +++ b/app/mailers/spree/order_mailer_decorator.rb @@ -39,7 +39,8 @@ Spree::OrderMailer.class_eval do :reply_to => @order.distributor.contact.email) end - def standing_order_placement_email(order, changes) + def standing_order_email(order, type, changes) + @type = type @changes = changes find_order(order) # Finds an order instance from an id subject = "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}" diff --git a/app/views/spree/order_mailer/standing_order_placement_email.html.haml b/app/views/spree/order_mailer/standing_order_email.html.haml similarity index 52% rename from app/views/spree/order_mailer/standing_order_placement_email.html.haml rename to app/views/spree/order_mailer/standing_order_email.html.haml index 2734536991..8714bbdc40 100644 --- a/app/views/spree/order_mailer/standing_order_placement_email.html.haml +++ b/app/views/spree/order_mailer/standing_order_email.html.haml @@ -7,22 +7,29 @@ %h3 = t :email_confirm_customer_greeting, name: @order.bill_address.firstname %h4 - = t :email_placement_intro_html, distributor: @order.distributor.name + - if @order.paid? + = t :email_so_payment_success_intro_html, distributor: @order.distributor.name + - else + = t("email_so_#{@type}_intro_html", distributor: @order.distributor.name) %table.column{:align => "left"} %tr %td{:align => "right"} %img.float-right{:src => "#{@order.distributor.logo.url(:medium)}"}/ %span.clear +%p.callout + = t("email_so_explainer_html", orders_close_at: l(@order.order_cycle.orders_close_at, format: "%a %b %d @ %I%p")) + = t("email_so_contact_distributor_html", distributor: @order.distributor.name, email: @order.distributor.email) + %p   %h4 = t :email_confirm_customer_number_html, number: @order.number %p - = t :email_placement_details_html, distributor: @order.distributor.name + = t("email_so_#{@type}_details_html", distributor: @order.distributor.name) - if @changes.any? %p.callout - = t :email_placement_changes + = t("email_so_#{type}_changes") = render 'order_summary' = render 'payment' = render 'shipping' diff --git a/config/locales/en.yml b/config/locales/en.yml index a08d13ab59..082a6e0d3c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1165,9 +1165,14 @@ See the %{link} to find out more about %{sitename}'s features and to start using email_payment_not_paid: NOT PAID email_payment_summary: Payment summary email_payment_method: "Paying via:" - email_placement_intro_html: "This email is to notify you that an order has been automatically placed with %{distributor} on your behalf." - email_placement_details_html: "Here are the details of your order for %{distributor}:" - email_placement_changes: "Unfortunately, not all products that you requested were available. The original quantities that you requested appear crossed-out below." + email_so_placement_intro_html: "You have a new order with %{distributor}" + email_so_placement_details_html: "Here are the details of your order for %{distributor}:" + email_so_placement_changes: "Unfortunately, not all products that you requested were available. The original quantities that you requested appear crossed-out below." + email_so_payment_success_intro_html: "An automatic payment has been processed for your order from %{distributor}." + email_so_explainer_html: "This order was automatically created on your behalf. You can make changes until orders close on %{orders_close_at}." + email_so_contact_distributor_html: "If you have any questions you can contact %{distributor} via %{email}." + email_so_confirmation_intro_html: "Your order with %{distributor} is now confirmed" + email_so_confirmation_details_html: "Here's everything you need to know about your order from %{distributor}:" email_shipping_delivery_details: Delivery details email_shipping_delivery_time: "Delivery on:" email_shipping_delivery_address: "Delivery address:"