简体   繁体   English

Magento-如何获取订单电子邮件中的商品总费用

[英]Magento - How to get total cost of items in order email

I have created a separate supplier purchase order email for each new order in Magento. 我为Magento中的每个新订单创建了单独的供应商采购订单电子邮件。 I can show line items with each base cost using {{var item.getBaseCost()}}; 我可以使用{{var item.getBaseCost()}}显示具有每个基本成本的订单项;

I need to show the Net Total of all costs (so the sum of all item costs, not sell prices). 我需要显示所有成本的净总计(因此,所有项目成本的总和,而不是售价)。

I have tried using {{var order.getBaseTotalInvoicedCost()}}; 我尝试使用{{var order.getBaseTotalInvoicedCost()}}; but it doesn't return a value in the email. 但它不会在电子邮件中返回任何值。

If anyone could shed some light on this I'd really appreciate it (two days in so far and unable to find a solution)! 如果有人可以对此有所了解,我将非常感激(到目前为止已经两天了,无法找到解决方案)!

Thanks in advance 提前致谢

You need to override this model app/code/core/Mage/Sales/Model/Order.php 您需要覆盖此模型app / code / core / Mage / Sales / Model / Order.php

You need to rewrite this method sendNewOrderEmail and you can find there following array you can add your custom variable and set it value. 您需要重写此方法sendNewOrderEmail,然后可以在其中找到以下数组,您可以添加自定义变量并将其设置为值。 In following example totalcost is custom variable. 在以下示例中,totalcost是自定义变量。

$mailer->setTemplateParams(array(
  'order'        =>  $this,
  'billing'      =>  $this->getBillingAddress(),
  'payment_html' => $paymentBlockHtml,
  'totalcost'  => $value
   ));

For email template you can use this variable {{var totalcost}} 对于电子邮件模板,您可以使用此变量{{var totalcost}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM