seog Posted November 11, 2012 Share Posted November 11, 2012 Hi there, I would like know how can the customer download his invoices from his account in order-detail instead of see it. I prefer that the customer can download directly when he click in PDF how worked in PS 1.4 What is the url for donwload it directly? best regards Link to comment Share on other sites More sharing options...
Dh42 Posted November 11, 2012 Share Posted November 11, 2012 Since it is a pdf and most people have acrobat installed they will download. You can put a msg tellingthe person to right click on the pdf and click save as. Or you can write a php script that will make the file download. Link to comment Share on other sites More sharing options...
seog Posted November 11, 2012 Author Share Posted November 11, 2012 Do you can say me the script code for download directly? best regards Link to comment Share on other sites More sharing options...
Dh42 Posted November 11, 2012 Share Posted November 11, 2012 Yes, I can. Where are you wanting the download to be from, the order history page? Link to comment Share on other sites More sharing options...
seog Posted November 11, 2012 Author Share Posted November 11, 2012 (edited) Yes, i need download it from history page (order-detail.tpl) the link to modify is: <a href="{$link->getPageLink('pdf-invoice', true)}?id_order={$order->id|intval}{if $is_guest}&secure_key={$order->secure_key}{/if}">{l s='Download your invoice as a PDF file'}</a> best regards Edited November 11, 2012 by seog (see edit history) Link to comment Share on other sites More sharing options...
Dh42 Posted November 11, 2012 Share Posted November 11, 2012 This is just an off the cuff without testing it out, but it should put you on the right path. Make a file called downloader.php, have this as the content <?php header('Content-disposition: attachment; filename='+ $invoicenumber); header('Content-type: application/pdf'); readfile($invoicenumber); ?> Then change your template code to something like <a href="http:yoursite.com/downloader.php?invoicenumber={$link->getPageLink('pdf-invoice', true)}?id_order={$order->id|intval}{if $is_guest}&secure_key={$order->secure_key}{/if}">{l s='Download your invoice as a PDF file'}</a> Link to comment Share on other sites More sharing options...
seog Posted November 12, 2012 Author Share Posted November 12, 2012 (edited) Thanks for your code, I tested it but the file don´t work, I think the code {$link->getPageLink('pdf-invoice', true)} take the main domain (http://www.mywebsite.com/) when i click then redirects to duplicate url: http://www.mywebsite.com/downloader.php?invoicenumber=http://www.mywebsite.com/index.php?controller=pdf-invoice?id_order=4 best regards Edited November 12, 2012 by seog (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts