Jump to content

Variable smarty in controller to a .tpl


Serial

Recommended Posts

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 :

post-1055497-0-89452000-1439821718_thumb.png

 

I want to see my variable here (black lines) :

post-1055497-0-08845700-1439821722_thumb.png

Link to comment
Share on other sites

 

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

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 by Serial (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...