How to add custom total row in Invoice PDFAdd item to totals in pdf invoiceAdd Minus Sign in Invoice PDF Totals BlockHow to add custom product attribute in PDF invoice?Change sort order totals in invoice PDFAdd TAX pecentage (%) in PDF invoice summaryAdd Custom Attribute to PDF InvoiceMagento - Add order id to invoice PDFinvoice pdf add imageCustom Invoice PDFHow to remove only Total Tax from invoice pdf?
What is the advantage of carrying a tripod and ND-filters when you could use image stacking instead?
Pronoun introduced before its antecedent
When writing an error prompt, should we end the sentence with a exclamation mark or a dot?
How to decline physical affection from a child whose parents are pressuring them?
How bad would a partial hash leak be, realistically?
Credit card offering 0.5 miles for every cent rounded up. Too good to be true?
Could the Missouri River be running while Lake Michigan was frozen several meters deep?
Will TSA allow me to carry a Continuous Positive Airway Pressure (CPAP) device?
1980s (or earlier) book where people live a long time but they have short memories
What do we gain with higher order logics?
What are they doing to this poor rocket?
Is the capacitor drawn or wired wrongly?
Why is the relationship between frequency and pitch exponential?
Did thousands of women die every year due to illegal abortions before Roe v. Wade?
correct term describing the action of sending a brand-new ship out into its first seafaring trip
Traffic law UK, pedestrians
How to pass a regex when finding a directory path in bash?
In this example, which path would a monster affected by the Dissonant Whispers spell take?
How could a possessed body begin to rot and decay while it is still alive?
Comma Code - Ch. 4 Automate the Boring Stuff
How were concentration and extermination camp guards recruited?
What happened to all the nuclear material being smuggled after the fall of the USSR?
Why is c4 bad when playing the London against a King's Indian?
How much water is needed to create a Katana capable of cutting flesh, bones and wood?
How to add custom total row in Invoice PDF
Add item to totals in pdf invoiceAdd Minus Sign in Invoice PDF Totals BlockHow to add custom product attribute in PDF invoice?Change sort order totals in invoice PDFAdd TAX pecentage (%) in PDF invoice summaryAdd Custom Attribute to PDF InvoiceMagento - Add order id to invoice PDFinvoice pdf add imageCustom Invoice PDFHow to remove only Total Tax from invoice pdf?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I added pdf.xml
in custom modules etc folder. But it is not reflecting in Invoice PDF.
I have debug and found that in the class MagentoSalesModelOrderPdfAbstractPdf
, on line no. 676 I get custom row values but those row values gets omitted after the statement $total->setOrder($order)->setSource($source);
protected function insertTotals($page, $source)
{
$order = $source->getOrder();
$totals = $this->_getTotalsList();
$lineBlock = ['lines' => [], 'height' => 15];
foreach ($totals as $total) {
echo "<pre>";print_r($total->getData());// I get custom row values here
$total->setOrder($order)->setSource($source);//But those get lost here
This is a protected function so I cannot add plugin also.
EDIT
Pdf.xml
<?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="custfee">
<title translate="true">Custom Fee</title>
<font_size>7</font_size>
<display_zero>true</display_zero>
<sort_order>100</sort_order>
</total>
</totals>
</config>
magento-2.1 invoice pdf totals
add a comment |
I added pdf.xml
in custom modules etc folder. But it is not reflecting in Invoice PDF.
I have debug and found that in the class MagentoSalesModelOrderPdfAbstractPdf
, on line no. 676 I get custom row values but those row values gets omitted after the statement $total->setOrder($order)->setSource($source);
protected function insertTotals($page, $source)
{
$order = $source->getOrder();
$totals = $this->_getTotalsList();
$lineBlock = ['lines' => [], 'height' => 15];
foreach ($totals as $total) {
echo "<pre>";print_r($total->getData());// I get custom row values here
$total->setOrder($order)->setSource($source);//But those get lost here
This is a protected function so I cannot add plugin also.
EDIT
Pdf.xml
<?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="custfee">
<title translate="true">Custom Fee</title>
<font_size>7</font_size>
<display_zero>true</display_zero>
<sort_order>100</sort_order>
</total>
</totals>
</config>
magento-2.1 invoice pdf totals
Can you share the code of pdf.xml first.
– Dhiren Vasoya
Feb 18 '17 at 4:34
Please see my edit
– piyush_systematix
Feb 18 '17 at 6:33
See my answer below.
– Khoa TruongDinh
Feb 20 '17 at 14:27
add a comment |
I added pdf.xml
in custom modules etc folder. But it is not reflecting in Invoice PDF.
I have debug and found that in the class MagentoSalesModelOrderPdfAbstractPdf
, on line no. 676 I get custom row values but those row values gets omitted after the statement $total->setOrder($order)->setSource($source);
protected function insertTotals($page, $source)
{
$order = $source->getOrder();
$totals = $this->_getTotalsList();
$lineBlock = ['lines' => [], 'height' => 15];
foreach ($totals as $total) {
echo "<pre>";print_r($total->getData());// I get custom row values here
$total->setOrder($order)->setSource($source);//But those get lost here
This is a protected function so I cannot add plugin also.
EDIT
Pdf.xml
<?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="custfee">
<title translate="true">Custom Fee</title>
<font_size>7</font_size>
<display_zero>true</display_zero>
<sort_order>100</sort_order>
</total>
</totals>
</config>
magento-2.1 invoice pdf totals
I added pdf.xml
in custom modules etc folder. But it is not reflecting in Invoice PDF.
I have debug and found that in the class MagentoSalesModelOrderPdfAbstractPdf
, on line no. 676 I get custom row values but those row values gets omitted after the statement $total->setOrder($order)->setSource($source);
protected function insertTotals($page, $source)
{
$order = $source->getOrder();
$totals = $this->_getTotalsList();
$lineBlock = ['lines' => [], 'height' => 15];
foreach ($totals as $total) {
echo "<pre>";print_r($total->getData());// I get custom row values here
$total->setOrder($order)->setSource($source);//But those get lost here
This is a protected function so I cannot add plugin also.
EDIT
Pdf.xml
<?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="custfee">
<title translate="true">Custom Fee</title>
<font_size>7</font_size>
<display_zero>true</display_zero>
<sort_order>100</sort_order>
</total>
</totals>
</config>
magento-2.1 invoice pdf totals
magento-2.1 invoice pdf totals
edited Feb 18 '17 at 7:43
Khoa TruongDinh
22.5k64491
22.5k64491
asked Feb 18 '17 at 3:51
piyush_systematixpiyush_systematix
96431930
96431930
Can you share the code of pdf.xml first.
– Dhiren Vasoya
Feb 18 '17 at 4:34
Please see my edit
– piyush_systematix
Feb 18 '17 at 6:33
See my answer below.
– Khoa TruongDinh
Feb 20 '17 at 14:27
add a comment |
Can you share the code of pdf.xml first.
– Dhiren Vasoya
Feb 18 '17 at 4:34
Please see my edit
– piyush_systematix
Feb 18 '17 at 6:33
See my answer below.
– Khoa TruongDinh
Feb 20 '17 at 14:27
Can you share the code of pdf.xml first.
– Dhiren Vasoya
Feb 18 '17 at 4:34
Can you share the code of pdf.xml first.
– Dhiren Vasoya
Feb 18 '17 at 4:34
Please see my edit
– piyush_systematix
Feb 18 '17 at 6:33
Please see my edit
– piyush_systematix
Feb 18 '17 at 6:33
See my answer below.
– Khoa TruongDinh
Feb 20 '17 at 14:27
See my answer below.
– Khoa TruongDinh
Feb 20 '17 at 14:27
add a comment |
1 Answer
1
active
oldest
votes
After debugging the MagentoSalesModelOrderPdfAbstractPdf::insertTotals()
:
$total->setOrder($order)->setSource($source);
On this line, Magento simply sets two Objects data to the current total object for using later. You can get the Order and Source (Invoice object - MagentoSalesModelOrderInvoice
) data:
$total->getOrder()->getData(); // Order data
$total->getSource()->getData(); // Invoice data
//Get specific data from total object
$total->getSourceField();
$total->getSortOrder();
If we're trying to var dump or print the total object, the page can be crashed because this object is "heavy" after set order and invoice source object.
I think your problem comes $total->canDisplay()
or $total->getTotalsForDisplay()
.
1) MagentoSalesModelOrderPdfTotalDefaultTotal::canDisplay()
. This method will check:
- Amount is not equal to zero.
- Or, in your
pdf.xml
config, you have declare<display_zero>true</display_zero>
. Set totrue
if you want to display zero amount.
2) MagentoSalesModelOrderPdfTotalDefaultTotal::getTotalsForDisplay()
: Get array of arrays with totals information for displaying in PDF
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f160586%2fhow-to-add-custom-total-row-in-invoice-pdf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
After debugging the MagentoSalesModelOrderPdfAbstractPdf::insertTotals()
:
$total->setOrder($order)->setSource($source);
On this line, Magento simply sets two Objects data to the current total object for using later. You can get the Order and Source (Invoice object - MagentoSalesModelOrderInvoice
) data:
$total->getOrder()->getData(); // Order data
$total->getSource()->getData(); // Invoice data
//Get specific data from total object
$total->getSourceField();
$total->getSortOrder();
If we're trying to var dump or print the total object, the page can be crashed because this object is "heavy" after set order and invoice source object.
I think your problem comes $total->canDisplay()
or $total->getTotalsForDisplay()
.
1) MagentoSalesModelOrderPdfTotalDefaultTotal::canDisplay()
. This method will check:
- Amount is not equal to zero.
- Or, in your
pdf.xml
config, you have declare<display_zero>true</display_zero>
. Set totrue
if you want to display zero amount.
2) MagentoSalesModelOrderPdfTotalDefaultTotal::getTotalsForDisplay()
: Get array of arrays with totals information for displaying in PDF
add a comment |
After debugging the MagentoSalesModelOrderPdfAbstractPdf::insertTotals()
:
$total->setOrder($order)->setSource($source);
On this line, Magento simply sets two Objects data to the current total object for using later. You can get the Order and Source (Invoice object - MagentoSalesModelOrderInvoice
) data:
$total->getOrder()->getData(); // Order data
$total->getSource()->getData(); // Invoice data
//Get specific data from total object
$total->getSourceField();
$total->getSortOrder();
If we're trying to var dump or print the total object, the page can be crashed because this object is "heavy" after set order and invoice source object.
I think your problem comes $total->canDisplay()
or $total->getTotalsForDisplay()
.
1) MagentoSalesModelOrderPdfTotalDefaultTotal::canDisplay()
. This method will check:
- Amount is not equal to zero.
- Or, in your
pdf.xml
config, you have declare<display_zero>true</display_zero>
. Set totrue
if you want to display zero amount.
2) MagentoSalesModelOrderPdfTotalDefaultTotal::getTotalsForDisplay()
: Get array of arrays with totals information for displaying in PDF
add a comment |
After debugging the MagentoSalesModelOrderPdfAbstractPdf::insertTotals()
:
$total->setOrder($order)->setSource($source);
On this line, Magento simply sets two Objects data to the current total object for using later. You can get the Order and Source (Invoice object - MagentoSalesModelOrderInvoice
) data:
$total->getOrder()->getData(); // Order data
$total->getSource()->getData(); // Invoice data
//Get specific data from total object
$total->getSourceField();
$total->getSortOrder();
If we're trying to var dump or print the total object, the page can be crashed because this object is "heavy" after set order and invoice source object.
I think your problem comes $total->canDisplay()
or $total->getTotalsForDisplay()
.
1) MagentoSalesModelOrderPdfTotalDefaultTotal::canDisplay()
. This method will check:
- Amount is not equal to zero.
- Or, in your
pdf.xml
config, you have declare<display_zero>true</display_zero>
. Set totrue
if you want to display zero amount.
2) MagentoSalesModelOrderPdfTotalDefaultTotal::getTotalsForDisplay()
: Get array of arrays with totals information for displaying in PDF
After debugging the MagentoSalesModelOrderPdfAbstractPdf::insertTotals()
:
$total->setOrder($order)->setSource($source);
On this line, Magento simply sets two Objects data to the current total object for using later. You can get the Order and Source (Invoice object - MagentoSalesModelOrderInvoice
) data:
$total->getOrder()->getData(); // Order data
$total->getSource()->getData(); // Invoice data
//Get specific data from total object
$total->getSourceField();
$total->getSortOrder();
If we're trying to var dump or print the total object, the page can be crashed because this object is "heavy" after set order and invoice source object.
I think your problem comes $total->canDisplay()
or $total->getTotalsForDisplay()
.
1) MagentoSalesModelOrderPdfTotalDefaultTotal::canDisplay()
. This method will check:
- Amount is not equal to zero.
- Or, in your
pdf.xml
config, you have declare<display_zero>true</display_zero>
. Set totrue
if you want to display zero amount.
2) MagentoSalesModelOrderPdfTotalDefaultTotal::getTotalsForDisplay()
: Get array of arrays with totals information for displaying in PDF
edited Feb 18 '17 at 10:01
answered Feb 18 '17 at 7:42
Khoa TruongDinhKhoa TruongDinh
22.5k64491
22.5k64491
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f160586%2fhow-to-add-custom-total-row-in-invoice-pdf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you share the code of pdf.xml first.
– Dhiren Vasoya
Feb 18 '17 at 4:34
Please see my edit
– piyush_systematix
Feb 18 '17 at 6:33
See my answer below.
– Khoa TruongDinh
Feb 20 '17 at 14:27