I am using an extension to add additional fee on Cash on Delivery payment gateway.
It is working fine but the COD fee is not showing in invoice pdf.
This issue only for the admin invoice pdf.
How can I add this information in pdf?
I am using an extension to add additional fee on Cash on Delivery payment gateway.
It is working fine but the COD fee is not showing in invoice pdf.
This issue only for the admin invoice pdf.
How can I add this information in pdf?
create pdf.xml file under etc folder
add add below code
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Sales:etc/pdf_file.xsd">
<totals>
<total name="cgst">
<title translate="true">Cgst</title>
<source_field>cgst_charge</source_field>
<display_zero>false</display_zero>
<sort_order>550</sort_order>
</total>
</config>
change code as per your need
You are required to create model: Name_space/module_name/Model/Sales/Pdf/Customfee.php
<?php
namespace Name_space\module_name\Model\Sales\Pdf;
class Customfee extends \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal
{
public function getTotalsForDisplay()
{
$order = $this->getOrder();
$amount = $order->getCash_on_delivery_fee(); // 'Cash_on_delivery_fee' replace with your custom attribute
$title = __($this->getTitle());
if ($this->getTitleSourceField()) {
$label = $title . ' (' . $this->getTitleDescription() . '):';
} else {
$label = $title . ':';
}
$fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
$total = ['amount' => '₹'.number_format($amount,2), 'label' => 'Cash on Delivery Charges', 'font_size' => $fontSize];
return [$total];
}
}