Customizing Magento Invoices for International Sales
When running an international e-commerce business on Magento, providing accurate information to customers is crucial. One common requirement is displaying the “Grand Total To Be Charged” in the base currency on customer invoices printed from the backend.
This figure ensures that customers understand exactly how much they’ll be charged before any currency conversions or additional fees are applied at their bank. By default, Magento doesn’t include this information on printed invoices, but it’s possible to add it with some custom code and layout changes.
Understanding the Base Currency
In Magento, you can set multiple store views with different currencies. The base currency is typically set as the primary currency for your store and is used in calculations behind the scenes. To check your current settings:
- Log into the Magento admin panel.
- Navigate to Stores > Configuration > General > Currency Setup.
Here, make sure you’ve correctly configured your base currency and any associated currency rates.
Adding the Grand Total Field to Invoice Layout
To add the “Grand Total To Be Charged” field to printed invoices:
- Locate the
vendor/magento/module-sales/view/frontend/templates/order/invoice.phtmlfile in your Magento installation. - Open this file and find the section where the invoice summary is displayed. You’ll see a
<tfoot>tag containing the order totals.
<tfoot>
<tr class="grand-total grand-total-last">
<th></th>
<td class="amount" colspan="4">Grand Total</td>
<td class="amount amount-grand-total">
<?php if ($this->getCurrency()): ?>
<?php echo $this->currency($order->formatPrice($order->getGrandTotal()), '', false) ?>
<?php else: ?>
<?php echo $order->formatPrice($order->getGrandTotal()) ?>
<?php endif; ?>
</td>
</tr>
</tfoot>
- Just above this
<tfoot>section, add the following new row to display the base currency total:
<tr class="grand-total grand-total-last">
<th></th>
<td class="amount" colspan="4">Grand Total (Base Currency)</td>
<td class="amount amount-grand-total">
<?php if ($this->getCurrency()): ?>
<?php echo $this->currency($order->formatPrice($order->getTotalDue()), '', false) ?>
<?php else: ?>
<?php echo $order->formatPrice($order->getTotalDue()) ?>
<?php endif; ?>
</td>
</tr>
This code adds a new row just above the existing “Grand Total” line. The getTotalDue method retrieves the total amount due in the base currency.
Conclusion
With these changes, your invoices will now display both the final grand total and the amount in the store’s base currency. This provides better transparency for international customers and helps manage expectations around currency fluctuations and additional bank fees.
Remember to always backup your files before making any modifications and test thoroughly on a staging environment first.
For more advanced customizations and layout changes, consider exploring Magento’s full page cache and theme development features at Laravel Company.