0

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?

0

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

  • Not working, I have added pdf.xml in the module. But the COD fee is not showing. – Vinod Kumar Mar 20 '18 at 9:53
  • there is a column of codcharge is you invoice table or not?? – Jigs Parmar Mar 20 '18 at 9:57
  • its working for me in my GST extension – Jigs Parmar Mar 20 '18 at 9:58
  • In my case, COD charge is 'cash_on_delivery_fee' in the table – Vinod Kumar Mar 20 '18 at 9:59
  • does you add any field in Invoice table or not??? – Jigs Parmar Mar 20 '18 at 9:59
0

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];
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.