Serial Posted August 17, 2015 Share Posted August 17, 2015 Hi, I have created a smarty variable in OrderController.php. The customer parameter this variabe when he is completing his order. With {debug}, I see my variable and it's work perfectly. Now, after completing his order, I want to display the variable in my back-office in Orders tab -> Order of the customer. How can I display the smarty variable who is created in OrderController.php in _shipping.tpl for example in /admin/themes/default/templates/controllers/orders/_shipping.tpl ? My variable : I want to see my variable here (black lines) : Link to comment Share on other sites More sharing options...
NishantVadgama Posted August 19, 2015 Share Posted August 19, 2015 For that you should save that data to database by overriding object of order or carrier as you like. and access that data from back and you can display that data in template as well. Link to comment Share on other sites More sharing options...
Serial Posted August 19, 2015 Author Share Posted August 19, 2015 Okay but I don't know how I can save that data to database and in what file of Prestashop ! I want to save this data in orders table. Link to comment Share on other sites More sharing options...
NishantVadgama Posted August 19, 2015 Share Posted August 19, 2015 Okay but I don't know how I can save that data to database and in what file of Prestashop ! I want to save this data in orders table. for that alter table of object which you want to add data in my example I have altered order object by following $sql[] = 'ALTER TABLE `'._DB_PREFIX_.'orders` ADD `test1` TINYINT(1)'; $sql[] = 'ALTER TABLE `'._DB_PREFIX_.'orders` ADD `test2` decimal(17,2)'; foreach ($sql as $query) if (Db::getInstance()->execute($query) == false) return false; and override object's class file and add new variable that you want to save like follows. class Order extends OrderCore { public $test1; public $test2; public function getFields() { $fields = parent::getFields(); $fields['test1'] = pSQL($this->test1); $fields['test2'] = pSQL($this->test2); return $fields; } } Link to comment Share on other sites More sharing options...
Serial Posted August 19, 2015 Author Share Posted August 19, 2015 Okay but where I do the SQL querys ? More, I see that the query doing "ALTER TABLE". We can't to this at the moment where the order is created in database ? Link to comment Share on other sites More sharing options...
NishantVadgama Posted August 19, 2015 Share Posted August 19, 2015 that alter query you have to perform while your module install method is called. meanwhile these all performs when your module is installing. Link to comment Share on other sites More sharing options...
Serial Posted August 19, 2015 Author Share Posted August 19, 2015 (edited) Why a module ? I don't want to do this in a module. (I don't update Prestashop later) I have evere created this2 fields in orders table. Now, I want to save my variable $choix_magasins during the process order of the customer. To recap, when the customer choose his delivery, he selects "Retreat in store". And in this same page (order-carrier.tpl), he selects in a list the store. His choice is register in my variable $choix_magasins. It works that you can see in my first post. After this, he confirms his order and when he confirms, Prestashop create a row in orders table. In this row, i want an other field where there is my variable here. That's it Edited August 19, 2015 by Serial (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