VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Kuubs on January 31, 2020, 16:49:26 PM

Title: Testing and debugging the invoice
Post by: Kuubs on January 31, 2020, 16:49:26 PM
Hello,

Looking at this page (https://docs.virtuemart.net/manual/general-concepts/205-invoices.html) it's possible to see the output of the invoice from every order so I can more easily debug and test the output of the invoice (instead of making a new order constantly). Unfortunately, the docs seem outdated, I don't get the view out of it.

Does someone know the correct working link for this? I want to see the invoice in plain html, see the mail invoice etc.

This does not work:

/index.php?option=com_virtuemart&view=invoice&layout=invoice&format=pdf&tmpl=component&virtuemart_order_id=7

or

/index.php?option=com_virtuemart&view=invoice&layout=mail&tmpl=component&virtuemart_order_id=7


Also when I check my url it seems different, and calls a task:

/index.php?option=com_virtuemart&view=orders&task=callInvoiceView&tmpl=component&virtuemart_order_id=7&layout=invoice

Anyone know the correct url?
Title: Re: Testing and debugging the invoice
Post by: GJC Web Design on January 31, 2020, 17:26:04 PM
no idea .. I just put die(); at the end of the invoice default template and toggle the status -- there's your complete html invoice
Title: Re: Testing and debugging the invoice
Post by: Kuubs on February 01, 2020, 14:07:45 PM
Quote from: GJC Web Design on January 31, 2020, 17:26:04 PM
no idea .. I just put die(); at the end of the invoice default template and toggle the status -- there's your complete html invoice

Ah ok thank you, I'll check it out to see if that works for me. Does that mean that the email does not get sent or anything?
Title: Re: Testing and debugging the invoice
Post by: GJC Web Design on February 02, 2020, 13:06:32 PM
just use a previously confirmed order with invoice, delete the invoice from your safe path folder invoices and click the invoice view icon on the order
Title: Re: Testing and debugging the invoice
Post by: Kuubs on February 02, 2020, 16:13:35 PM
Quote from: GJC Web Design on February 02, 2020, 13:06:32 PM
just use a previously confirmed order with invoice, delete the invoice from your safe path folder invoices and click the invoice view icon on the order

CanI also debug the email templates with this method?
Title: Re: Testing and debugging the invoice
Post by: GJC Web Design on February 02, 2020, 16:26:41 PM
yes.. die() the default but there is already an admin setting for email debugging
Title: Re: Testing and debugging the invoice
Post by: Kuubs on February 03, 2020, 09:34:52 AM
Quote from: GJC Web Design on February 02, 2020, 16:26:41 PM
yes.. die() the default but there is already an admin setting for email debugging

Could you tel me where? Because I saw tha you can use a certain link, but that is not working anymore with the newest VM
Title: Re: Testing and debugging the invoice
Post by: GJC Web Design on February 03, 2020, 10:47:31 AM
?
Title: Re: Testing and debugging the invoice
Post by: Kuubs on February 06, 2020, 11:50:31 AM
How can I debug the PDF invoice? I tried add die() at the end but it still generates the PDF instead of displaying the HTML first...
Title: Re: Testing and debugging the invoice
Post by: GJC Web Design on February 06, 2020, 11:54:14 AM
Quotejust use a previously confirmed order with invoice, delete the invoice from your safe path folder invoices
!!!
Title: Re: Testing and debugging the invoice
Post by: Kuubs on February 06, 2020, 12:26:56 PM
Quote from: GJC Web Design on February 06, 2020, 11:54:14 AM
Quotejust use a previously confirmed order with invoice, delete the invoice from your safe path folder invoices
!!!

I understand that but is it possible to get the HTML first? That is easier debugging for me instead of checking the PDF constantly
Title: Re: Testing and debugging the invoice
Post by: GJC Web Design on February 06, 2020, 12:59:32 PM
it does stop on the html if u have the die() in the correct file

templates\xxxx\html\com_virtuemart\invoice\invoice.php
Title: Re: Testing and debugging the invoice
Post by: Kuubs on February 06, 2020, 13:10:32 PM
Quote from: GJC Web Design on February 06, 2020, 12:59:32 PM
it does stop on the html if u have the die() in the correct file

templates\xxxx\html\com_virtuemart\invoice\invoice.php

That is weird, because I have that in my file, except it just starts the download...
Title: Re: Testing and debugging the invoice
Post by: Kuubs on February 10, 2020, 07:49:16 AM
Ok I think I have to just download the invoice over and over again. No big deal. But the problem lies in the fact that I can't seem to make the invoice totally blank. It keeps printing the line above and below the page, and also the vendor's logo. How can I amke the PDF totally blank?


Found it, it's in the Store page and then Templating/Invoices where you can disbale the lines and header.
Title: Re: Testing and debugging the invoice
Post by: derek webster on February 08, 2023, 15:24:21 PM
Not sure if this helps anyone but I think I figured it out witn the following
just need to change the header
This lets me see the PDF in browser instead of downloading

hope it helps!!

components/com_virtuemart/controllers/invoice.php
replace these lines
$contentDisposition = 'attachment';
with
$contentDisposition = 'inline';

Oh And possibly change th path here
return VmPdf::createVmPdf($view, $path, 'F', $metadata);
to
return VmPdf::createVmPdf($view, $path.'test', 'F', $metadata);

this lets you refresh in the browser and see any changes

I found solution here
https://stackoverflow.com/questions/6293893/how-do-i-force-files-to-open-in-the-browser-instead-of-downloading-pdf
Title: Re: Testing and debugging the invoice
Post by: jenkinhill on February 08, 2023, 16:44:35 PM
Quote from: derek webster on February 08, 2023, 15:24:21 PM

This lets me see the PDF in browser instead of downloading


When developing I switch Firefox's PDF handling application to "Open in Firefox". This opens the PDF in a new tab (and in my FF version also downloads the file, so I generally leave the browser view setting on).