4

我正在尝试在结帐电子邮件后插入文本。我在 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') %>

所以我不知道如何在此之后添加一些文本,没有任何选择器:

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

你能告诉我任何解决这个问题的方法吗?

4

2 回答 2

3

在此处找到解决方案:如何从 products.images 添加 Spree 电子邮件附件(图像)?. 我创建了一个新模板/app/views/spree/order_mailer/confirm_email.text.erb并在此处添加了我的代码。

于 2013-10-03T07:35:04.857 回答
0

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

于 2014-02-01T07:43:18.333 回答