Php Magento-发票上的总金额

Php Magento-发票上的总金额,php,magento,Php,Magento,当客户从Magento商店购买物品时,他们会收到一封电子邮件确认,其中底部有一行“总计要收费”。这显示以门店基础货币表示的合计 我想将此数字添加到从后端打印的发票中。如何做到这一点?让我们看看发生了什么。 我们可以从url(www.example.com/index.php/admin/sales\u invoice/view/invoice\u id/[some\u id]/)中看到,Mage\u Adminhtml\u sales\u Order\u InvoiceController执行了

当客户从Magento商店购买物品时,他们会收到一封电子邮件确认,其中底部有一行“总计要收费”。这显示以门店基础货币表示的合计

我想将此数字添加到从后端打印的发票中。如何做到这一点?

让我们看看发生了什么。 我们可以从url(www.example.com/index.php/admin/sales\u invoice/view/invoice\u id/[some\u id]/)中看到,
Mage\u Adminhtml\u sales\u Order\u InvoiceController
执行了
视图
操作,这与
相对应,让我们看看发生了什么。

我们可以从url(www.example.com/index.php/admin/sales\u invoice/view/invoice\u id/[some\u id]/)中看到,执行了Mage\u Adminhtml\u sales\u Order\u InvoiceController的
视图
操作,这与
相对应。简言之,您只需添加一些XML:

<global>
    <pdf>
       <totals>
            <mygrand_total translate="title">
                <title>Grand Total To Be Charged</title>
                <source_field>base_grand_total</source_field>
                <font_size>8</font_size>
                <display_zero>1</display_zero>
                <sort_order>705</sort_order>
            </mygrand_total>
       </totals>
    </pdf>
</global>

简而言之,您只需添加一些XML:

<global>
    <pdf>
       <totals>
            <mygrand_total translate="title">
                <title>Grand Total To Be Charged</title>
                <source_field>base_grand_total</source_field>
                <font_size>8</font_size>
                <display_zero>1</display_zero>
                <sort_order>705</sort_order>
            </mygrand_total>
       </totals>
    </pdf>
</global>

我这样做了,几乎成功了。它添加了基本总数,但使用了错误的货币符号。您可以从我的发票中看到一个快照,基本总额实际上应该是93.33英镑。虽然您最初的问题没有提到货币差异,但这应该有助于
Mage::app()->getConfig()->getNode('default/')。Mage\u目录\模型\货币::XML\u路径\货币\基础)我将在哪里放置此代码?我相信我最初的问题确实提到了货币“.要收费的总额。这显示了商店基础货币中的总额。”。您的解决方案显示的是总额,但不是基础货币(英镑)。相反,它显示了客户退房时使用的货币。很抱歉,我重新阅读了您的问题,其中有一些货币差异的迹象。您可能想在
/app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php中研究覆盖
getTotalsForDisplay
,我这样做了,几乎成功了。它添加了基本总数,但使用了错误的货币符号。您可以从我的发票中看到一个快照,基本总额实际上应该是93.33英镑。虽然您最初的问题没有提到货币差异,但这应该有助于
Mage::app()->getConfig()->getNode('default/')。Mage\u目录\模型\货币::XML\u路径\货币\基础)我将在哪里放置此代码?我相信我最初的问题确实提到了货币“.要收费的总额。这显示了商店基础货币中的总额。”。您的解决方案显示的是总额,但不是基础货币(英镑)。相反,它显示了客户退房时使用的货币。很抱歉,我重新阅读了您的问题,其中有一些货币差异的迹象。您可能希望在
/app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php中查看覆盖
getTotalsForDisplay
public function getPrintUrl()
{
    return $this->getUrl('*/*/print', array(
        'invoice_id' => $this->getInvoice()->getId()
    ));
}
/**
 * Create pdf for current invoice
 */
public function printAction()
{
    $this->_initInvoice();
    parent::printAction();
}
public function printAction()
{
    if ($invoiceId = $this->getRequest()->getParam('invoice_id')) {
        if ($invoice = Mage::getModel('sales/order_invoice')->load($invoiceId)) {
            $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));
            $this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').
                '.pdf', $pdf->render(), 'application/pdf');
        }
    }
    else {
        $this->_forward('noRoute');
    }
}
<global>
    <pdf>
       <totals>
            <mygrand_total translate="title">
                <title>Grand Total To Be Charged</title>
                <source_field>base_grand_total</source_field>
                <font_size>8</font_size>
                <display_zero>1</display_zero>
                <sort_order>705</sort_order>
            </mygrand_total>
       </totals>
    </pdf>
</global>
protected function _getTotalsList($source)
{
    $totals = Mage::getConfig()->getNode('global/pdf/totals')->asArray();
    usort($totals, array($this, '_sortTotalsList'));
    $totalModels = array();
    foreach ($totals as $index => $totalInfo) {
        if (!empty($totalInfo['model'])) {
            $totalModel = Mage::getModel($totalInfo['model']);
            if ($totalModel instanceof Mage_Sales_Model_Order_Pdf_Total_Default) {
                $totalInfo['model'] = $totalModel;
            } else {
                Mage::throwException(
                    Mage::helper('sales')->__('PDF total model should extend Mage_Sales_Model_Order_Pdf_Total_Default')
                );
            }
        } else {
            $totalModel = Mage::getModel($this->_defaultTotalModel);
        }
        $totalModel->setData($totalInfo);
        $totalModels[] = $totalModel;
    }

    return $totalModels;
}