Rissinko Posted October 17, 2016 Share Posted October 17, 2016 Hi, i am really confused about how to add variable to the class. I need to add variale "$orderstatus" to the classes/pdf/HTMLTemplateInvoice.php to the __construct. so i did this : - created HTMLTemplateInvoice.php in override/classes/pdf/ and put in this : class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore { fasdsdfsd public function __construct(OrderInvoice $order_invoice, $smarty, $bulk_mode = false) { $orderstatus = $this->order->current_state; $this->smarty->assign(array( 'orderstatus' => $orderstatus, )); parent::__construct(OrderInvoice $order_invoice, $smarty, $bulk_mode); } } I know that there is something wrong in it but i cant find what. Thanks for help. Link to comment Share on other sites More sharing options...
rocky Posted October 17, 2016 Share Posted October 17, 2016 The problem is that you're using $this->smarty before it is initialised in the parent constructor. You should move the parent::__construct line to the top of the constructor. Link to comment Share on other sites More sharing options...
Rissinko Posted October 17, 2016 Author Share Posted October 17, 2016 ok thanks i had it like this but it didn't work ... is this only thing that i have wrong ? Link to comment Share on other sites More sharing options...
rocky Posted October 18, 2016 Share Posted October 18, 2016 The fasdsdfsd line is also wrong. Perhaps you need to move the code to one of the functions that calls a TPL file instead of the constructor. Link to comment Share on other sites More sharing options...
Rissinko Posted November 9, 2016 Author Share Posted November 9, 2016 (edited) hmm I tried it use like this ... <?php class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore { public function __construct(OrderInvoice $order_invoice, $smarty, $bulk_mode = false) { parent::__construct(); $orderstatus = $this->order->current_state; $this->smarty->assign(array( 'orderstatus' => $orderstatus, )); } } and i Got this error from overrided file Fatal error: Call to a member function getInvoiceNumberFormatted() on a non-object in /public_html/classes/pdf/HTMLTemplateInvoice.php on line 59 Any suggestions ?? Edited November 9, 2016 by Rissinko (see edit history) 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