jvels Posted May 11, 2013 Share Posted May 11, 2013 Hi I have done some modifucation to GetFileController.php so if the customer buy a downloadable product (a pdf file) then the pdf file are stamped with some information. I would like to get the customer email, name etc. When the customer download the file I have the information: <sha1-filename>-<hashOrder> Are there "easy" way to get the customer information from the hashorder?? Best Regards Jesper Link to comment Share on other sites More sharing options...
bellini13 Posted May 12, 2013 Share Posted May 12, 2013 when you say you would like to get the customer details, could you further clarify? Are you saying from within the GetFileController? Link to comment Share on other sites More sharing options...
jvels Posted May 12, 2013 Author Share Posted May 12, 2013 Hi Yes, it is because I have done a modification in the GetFileController, so when it is a pdf file I have added a exception, where I use TCPDF to add additional information to the downloadable product (a pdf file). And some of the information I would like to add to the pdf are who there have purchased the file (add a watermark with TCPDF). I can of cause from the download hash, get the order id, and from the order id get the customer, and then the info about the customer (with pure durty sql, but I do not thing it is a good idea.) /Jesper Link to comment Share on other sites More sharing options...
bellini13 Posted May 13, 2013 Share Posted May 13, 2013 Hi Jesper, there are 2 paths to account for here. 1) The customer is already logged into the site, and clicked the download link from their email or order history. 2) The customer is not logged into the site, and clicked the download link from their email or order history. In path #1, the customer context is already loaded, and you can simply access the customer object using this $this->context->customer->email $this->context->customer->lastname In path 2, the customer is not logged in and therefore you have no choice but to use the information you have to locate the customer. You should not need to use any customer sql. From the Order, you get the customer id and then create the Customer object $id_customer=$order->id_customer; $customer= new Customer((int)$id_customer); if (!Validate::isLoadedObject($customer)) //do something here Personally, I alter the GetFileController and disable path 2, which forces a customer to log into the site. It prevents sharing of the download link. 1 Link to comment Share on other sites More sharing options...
vekia Posted May 13, 2013 Share Posted May 13, 2013 @jvels let us know whats going on in this case, i think that problem is solved, but I'm waiting for your opinion Link to comment Share on other sites More sharing options...
jvels Posted May 13, 2013 Author Share Posted May 13, 2013 Hi Thanks bellini13 It works. Here are my little hack in GetFileController.php each time the file type are pdf my code are used. The best soultion would have a checkbox at the product in the admin, where it should be possible to enable password protection of the pdf. if ($mimeType = 'application/pdf') { $pdf = new FPDI(); if (file_exists($file)){ $pagecount = $pdf->setSourceFile($file); } else { return FALSE; } $tpl = $pdf->importPage(1); $pdf->addPage(); $pdf->useTemplate($tpl, 1, 1, 0, 0, TRUE); $pdf->SetProtection($permissions=array('print', 'copy'), $user_pass=$this->context->customer->email, $owner_pass=null, $mode=0, $pubkeys=null); $pdf->Output($filename, 'D'); } else { /* Set headers for download */ header('Content-Transfer-Encoding: binary'); header('Content-Type: '.$mimeType); header('Content-Length: '.filesize($file)); header('Content-Disposition: attachment; filename="'.$filename.'"'); ob_end_flush(); $fp = fopen($file, 'rb'); while (!feof($fp)) echo fgets($fp, 16384); exit; } Link to comment Share on other sites More sharing options...
vekia Posted May 13, 2013 Share Posted May 13, 2013 hello thanks for all, im going to mark this thread as solved regards Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now