Extract format for order cycle closing in emails

Using a helper for this, but this can be changed to look up a
translation key.
This commit is contained in:
Kristina Lim
2018-08-30 02:58:02 +08:00
parent dc4037474d
commit ad8b120e48
5 changed files with 12 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
module ShopMailHelper
# Long datetime format string used in emails to customers
#
# Example: "Fri Aug 31 @ 11:00PM"
def mail_long_datetime_format
"%a %b %d @ %l:%M%p"
end
end

View File

@@ -1,5 +1,6 @@
class SubscriptionMailer < Spree::BaseMailer
helper CheckoutHelper
helper ShopMailHelper
def confirmation_email(order)
@type = 'confirmation'

View File

@@ -4,7 +4,7 @@
%p.callout
= t("email_so_confirmation_explainer_html")
= t("email_so_edit_false_html",
orders_close_at: l(@order.order_cycle.orders_close_at, format: "%a %b %d @ %l:%M%p"),
orders_close_at: l(@order.order_cycle.orders_close_at, format: mail_long_datetime_format),
order_url: spree.order_url(@order))
= t("email_so_contact_distributor_html", distributor: @order.distributor.name, email: @order.distributor.contact.email)

View File

@@ -3,7 +3,7 @@
%p.callout
= t("email_so_failed_payment_explainer_html", distributor: @order.distributor.name)
= t("email_so_edit_false_html",
orders_close_at: l(@order.order_cycle.orders_close_at, format: "%a %b %d @ %l:%M%p"),
orders_close_at: l(@order.order_cycle.orders_close_at, format: mail_long_datetime_format),
order_url: spree.order_url(@order))
= t("email_so_contact_distributor_html", distributor: @order.distributor.name, email: @order.distributor.contact.email)

View File

@@ -5,7 +5,7 @@
= t("email_so_placement_explainer_html")
- allow_changes = !!@order.distributor.allow_order_changes?
= t("email_so_edit_#{allow_changes}_html",
orders_close_at: l(@order.order_cycle.orders_close_at, format: "%a %b %d @ %l:%M%p"),
orders_close_at: l(@order.order_cycle.orders_close_at, format: mail_long_datetime_format),
order_url: spree.order_url(@order))
= t("email_so_contact_distributor_html", distributor: @order.distributor.name, email: @order.distributor.contact.email)