编辑Magento销售电子邮件支付块 [英] Editing Magento sales e-mail payment block

查看:144
本文介绍了编辑Magento销售电子邮件支付块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

app \locale\en_US\template\email\sales\order_new.html 是有问题的文件。

在不影响网站其他部分的情况下,如何编辑{{var payment_html}}?

How would one go about editing {{var payment_html}} without affecting other sections of the site?

似乎该部分来自: app \design\frontend\base\default\template\payment\info\default.phtml

我是正确的吗?但该文件用于网站的其他地方。这是正确的吗?

Am I correct about this? But that file is used in other places on the site. Is that correct too?

我想创建一个单独的文件,说 default_email.phtml ,分开样式,并且有order_new.phtml包含新的文件。

I want to create a separate file, say default_email.phtml, style it separately, and have order_new.phtml include the new file instead.

我假设我需要包含我的 default_email.phtml 文件在 layout\ ***。xml 中。我该怎么做?

I assume that I need to include my default_email.phtml file in layout\***.xml. Where would I do this?

推荐答案

我做的第一件事是在Magento的源代码中进行搜索。假设在 payment_html 上搜索的地方处理 {{var payment_html}}
几个结果匹配搜索;

The first thing I did was a search in the source code of Magento. Assuming the {{var payment_html}} is processed somewhere I searched on payment_html. Several results are matching the search;

Mage_Sales_Model_Order
Mage_Sales_Model_Order_Creditmemo
Mage_Sales_Model_Order_Invoice
Mage_Sales_Model_Order_Shipment

所以这个付款块的信息必须在那里。我采取了 Mage_Sales_Model_Order 并检查变量 $ paymentBlockHtml 。这指向了通过付款信息填充付款块的进一步逻辑。它正在创建一个块,看起来这是不容易扩展/更改/修改的第一眼看。
是的,我们可以将模板应用于特定(付款)块类型,因为创建块,但是我们不能轻易地检查我们要加载的块。另外,模板在 Mage_Payment_Block_Info

So the information for that payment block has to be in there. I took Mage_Sales_Model_Order and checked the variable $paymentBlockHtml. This is pointed to further logic to fill the payment block by payment information. It's creating a block and it looks like this is not easy to extend/change/modify on the first look. Yes, we can apply a template to the specific (payment) block type since there’s a block created, but we can’t easily check which block we want to load. Also the template is overruled in the construct of Mage_Payment_Block_Info

的构造中被推翻我们来检查另一种方式。 >

Let’s check the other way.

让我们做一些很酷的事情,为什么我们不向包含正确信息的电子邮件添加一个块,但是更重要的是可以切换到正确的案件。由于模板解析器用于解析变量和布局句柄,我们可以添加以下代码而不是 {{var payment_html}} 块,并在块本身中检索该信息。

Let’s do something cool, why we don’t add a block to the email which contains the correct information but more important where it’s possible to make a switch to the correct case. Since template parser is used for parsing the variables and layout handles we could add the following on instead of the {{var payment_html}} block and retrieving that information in the block itself.

{{block type='core/template' template='email/templatename.phtml'}}

以上代码将电子邮件/ templatename.phtml解析为电子邮件,这意味着您可以在该模板中执行任何操作显示正确的数据。
在我们可以检索此模板中的付款数据之前,我们必须使用订单数据添加订单参数。这很简单;

The above code is parsing the email/templatename.phtml into the email, which means that you could do anything in that template to show the correct data. Before we can retrieve the payment data in this template we have to add the order argument with the order data. That’s quite simple;

{{block type='core/template' order=$order template='email/templatename.phtml'}}

在模板中,我们可以执行 $ this-> getOrder () - > getPayment()以检索付款信息,或 $ this-> getOrder-> getPayment() - > toHtml()或以另一种方式处理数据。

In the template we can do $this->getOrder()->getPayment() to retrieve the payment information, or $this->getOrder->getPayment()->toHtml() or process the data in another way.

奖金;
另一个解决方案是使用布局句柄并设置正确的模板并在layout.xml中键入,下面是同一电子邮件中订单项的示例。它的工作方式与块相同,但只有布局xml中的某些设置。

Bonus; Another solution is working with layout handles and set the correct template and type in the layout.xml, below an example for the order items in the same email. It’s working the same as the block, but only with some settings in the layout xml.

{{layout handle="sales_email_order_items" order=$order}}

这篇关于编辑Magento销售电子邮件支付块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆