irabbit Posted November 1, 2016 Share Posted November 1, 2016 (edited) How to change PDF filename to order-reference code? I tried to change HTMLTemplateInvoice.php getFilename function. $this->id_order->order_reference and $order->getUniqReference() dosn't work. 1.6 Presta Edited November 1, 2016 by irabbit (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted November 1, 2016 Share Posted November 1, 2016 Perhaps the reference code is being formatted at an integer? It worked when I used the following: /** * Returns the template filename * * @return string filename */ public function getFilename() { /* $id_lang = Context::getContext()->language->id; $id_shop = (int)$this->order->id_shop; $format = '%1$s%2$06d'; if (Configuration::get('PS_INVOICE_USE_YEAR')) { $format = Configuration::get('PS_INVOICE_YEAR_POS') ? '%1$s%3$s-%2$06d' : '%1$s%2$06d-%3$s'; } return sprintf( $format, Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop), $this->order_invoice->number, date('Y', strtotime($this->order_invoice->date_add)) ).'.pdf'; */ return $this->order->reference.'.pdf'; } Link to comment Share on other sites More sharing options...
irabbit Posted November 2, 2016 Author Share Posted November 2, 2016 Thanks, rocky. It works good. return $this->order->reference.'.pdf'; — It works good. One more thing. How i can add some text before reference? Link to comment Share on other sites More sharing options...
rocky Posted November 2, 2016 Share Posted November 2, 2016 Just add it before: return 'Prefix'.$this->order->reference.'.pdf'; 1 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