PDF invoice

  • Posts: 137
  • Thank you received: 2
13 years 9 months ago #9505

Hi!

Is it possible to attach the invoice as a PDF instead of HTML to the confirmation mail send to a customer after an order is created?

Best regards

The following user(s) said Thank You: klimmbimm

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 9 months ago #9506

Hi,

Well, everything is possible, if you know how to code it :)

In the business edition of HikaShop, you can edit the emails via the menu System->Emails. There, you will be able to use the joomla PDF library to generate a PDF. It's not so easy and only on joomla 1.5. On 1.6, the library was removed. You can always use another PDF library.
You can then attach it to the email quite easily with a few lines of code:
$attachObj = null;
$attachObj->name = 'invoice.pdf';
$attachObj->filename = '/home/user/www/path/to/invoice.pdf';
$attachObj->url = ' www.mywebsite.com/path/to/invoice.pdf ';
$mail->attachments = array($attachObj);

Please Log in or Create an account to join the conversation.

  • Posts: 137
  • Thank you received: 2
13 years 8 months ago #10805

Which PDF library would you recommend to use?

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 8 months ago #10806

You can use the same one as in joomla 1.5 : www.tcpdf.org/

Please Log in or Create an account to join the conversation.

  • Posts: 137
  • Thank you received: 2
13 years 8 months ago #10812

Where or how can I get the HTML stream to write it with the PDF library to a PDF-file?

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 8 months ago #10813

In the email itself...The email has the summary of the order in it. So you can directly use it in the email to generate the PDF and attach it to the email.

Please Log in or Create an account to join the conversation.

  • Posts: 137
  • Thank you received: 2
13 years 8 months ago #10825

nicolas wrote:

In the email itself...The email has the summary of the order in it. So you can directly use it in the email to generate the PDF and attach it to the email.

You mean in the HTML version textfield?

But how can I get the full HTML stream, to add it to the PDF, like
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', [b]$html[/b]...

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 8 months ago #10843

Yes, the HTML version.

You can add a ob_start(); at the beginning of the email.
Then, at the end of it:
$html = ob_get_contents();
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html...

Please Log in or Create an account to join the conversation.

  • Posts: 137
  • Thank you received: 2
13 years 8 months ago #11560

I need to have 2 different HTML strings to have a good HTML-layout in the mail itself and also in the PDF.

I tried it with

$html = <<<EOD
<div style="background-color:...

but I do have problems when I come to PHP-Code

<?php echo JText::sprintf('HI_CUSTOMER',@$data->customer->name);?>

How can I solve this problem?

Thanks!

Last edit: 13 years 8 months ago by emergentec.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 8 months ago #11571

Just copy/paste the default email to have it displayed twice. Then, for one of the two, you can use the code I posted above and do your customizations for the PDF.

Please Log in or Create an account to join the conversation.

  • Posts: 137
  • Thank you received: 2
13 years 8 months ago #12087

nicolas wrote:

Just copy/paste the default email to have it displayed twice. Then, for one of the two, you can use the code I posted above and do your customizations for the PDF.

Then the HTML invoice is displayed twice in the mail, which isn't really a solution.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 8 months ago #12093

No.

If have such script nothing is displayed :
<?php ob_start(); ?>
<p>some text that won't be displayed<?php echo ' and some more text'; ?></p>
<?php $html = ob_get_clean(); ?>

and you have all your HTML in the $html variable. You can use it to do whatever you want, independently from the display.

Please Log in or Create an account to join the conversation.

  • Posts: 137
  • Thank you received: 2
13 years 8 months ago #12217

I used "ob_get_contents();" from a post above, then it's displayed twice. Thanks! :)

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
11 years 2 hours ago #134362

Please note that there is now a PDF invoice plugin available for HikaShop:
www.hikashop.com/component/hikashop/product/cid-18.html

Please Log in or Create an account to join the conversation.

  • Posts: 440
  • Thank you received: 20
  • Hikashop Essential
10 years 10 months ago #139050

Out of interest does this plugin just attach a PDF version of what is already in Hikashop as an invoice, is there an example of what the PDF looks like?

Thanks

Dave B)

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
10 years 10 months ago #139070

Hi Dave,
Note that you can directly test it through the back-end of the Hikashop demo website, and :
- Go to the page "Hikashop->Orders" and edit one of the existing orders
- Use the Invoice button then a pdf file will be downloaded
Note that the display of the PDF invoice is customizable through the file: "plugins/hikashop/attachinvoice/attachinvoice/invoice.php".

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
10 years 4 months ago #162263

Hi all,

does the PDF-plugin also work with the multivendor option ? Means, will the address and the logo of the vendor appear in the PDF ?

Best regards
Torsten

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
10 years 4 months ago #162269

It's a PHP script, so pretty much anything is possible even if not set yet, provided it's in the database and on file, and a bit of code. You might need or want to re-style, anyway.
As I said elsewhere before, the PDF Invoice Plugin is one of the better investments I've made in the course of my current project. And Jerome (for HikaMarket particularly) and the other boys here are ultimately helpful. (Hint: When it's the time, best post in the relevant forums, not here in the archives. ;) )


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Last edit: 10 years 4 months ago by lousyfool.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
10 years 4 months ago #162302

Hi,

By default, it's not the logo/address of the vendor which is displayed in the PDF invoice of that plugin. But as lousyfool points out, it can be changed in the file plugins/hikashop/attachinvoice/attachinvoice/invoice.php
Now I'm not the specialist on HikaMarket, so if you need more details on what to put in order to get the data from HikaMarket, I would recommend to that you open a new thread in the HikaMarket section of the forum where Jerome will be able to answer you about that.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
10 years 4 months ago #162811

Many thanks, guys, for the update. I will post it in the forum.

Please Log in or Create an account to join the conversation.

Time to create page: 0.138 seconds
Powered by Kunena Forum