4
votes

I am trying to insert a text after checkout email message. I'm found template in spree/order_mailer/confirm_email.text.erb

<%= Spree.t('order_mailer.confirm_email.dear_customer') %>

<%= Spree.t('order_mailer.confirm_email.instructions') %>

============================================================
<%= Spree.t('order_mailer.confirm_email.order_summary') %>
============================================================
<% @order.line_items.each do |item| %>
<%= item.variant.sku %> <%= raw(item.variant.product.name) %> <%= raw(item.variant.options_text) -%> (<%=item.quantity%>) @ <%= item.single_money %> = <%= item.display_amount %>
<% end %>
============================================================
<%= Spree.t('order_mailer.confirm_email.subtotal', :subtotal => @order.display_item_total) %>

<% @order.adjustments.eligible.each do |adjustment| %>
  <%= raw(adjustment.label) %> <%= adjustment.display_amount %>
<% end %>

<%= Spree.t('order_mailer.confirm_email.total', :total => @order.display_total) %>

<%= Spree.t('order_mailer.confirm_email.thanks') %>

So I don't know how to add some text after this, there are no any selectors:

Deface::Override.new(
    :virtual_path => "spree/order_mailer/confirm_email",
    :insert_bottom => '*',
    :partial      => "spree/shared/confirm_email",    
    :name         => "confirm_email",
    :original     => '3a8c298b4d9884a4d9f842b23fcb4fabf92ef0f3'
)

Could you advice me any ways to solve this?

2

2 Answers

3
votes

Found solution here: How to add Spree email attachment (image) from products.images?. I'm created a new template /app/views/spree/order_mailer/confirm_email.text.erb and added my code here.

0
votes

Short answer: You can't.

Long Answer: Unfortunately you cannot deface a text file as I tried recently. Reason is Deface needs structured data to parse the view, as detailed in the Spree Group discussion. Only .deface, .html.erb.deface, .html.haml.deface or .html.slim.deface are the only override files allowed:

Deface::DSL does not know how to read '/spree/app/overrides/spree/order_mailer/confirm_email.text/append_text.text.erb.deface'. 
Override files should end with just .deface, .html.erb.deface, .html.haml.deface or .html.slim.deface

Interestingly deface is actually able to test the selector on the file but still cannot override:

$ bundle exec rake deface:test_selector['spree/order_mailer/confirm_email.text',"erb:contains('order_mailer.confirm_email.thanks')"]

Querying 'spree/order_mailer/confirm_email.text' for 'erb:contains('order_mailer.confirm_email.thanks')'
---------------- Match 1 ----------------
<%= Spree.t('order_mailer.confirm_email.thanks') %>

The only thing you can do then is to override the file by creating app/views/spree/order_mailer/confirm_email.text.erb