Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

добавить массив в контроллер order.php


 Share

Recommended Posts

Подскажите, пожалуйси, как правильно добавить новый массив контроллер order.php (в админке)? В могдели создал функцию:

public function getMyVars($order_id) {
	$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_variables WHERE order_id = '" . (int)$order_id . "'");

	return $query->rows;
}

Сосивил массив по аналогии с суещёствующими:

$data['order_vars'] = array();
$my_vars = $this->model_sale_order->getMyVars($this->request->get['order_id']);
foreach ($my_vars as $my_var) {
	$data['order_vars'][] = array(
		'var_id'	=> $my_var['var_id'],
		'var1'		=> $my_var['var1']
	);
}

Но при вызове переменных в шаблоне получается "Undefined...".

<?php foreach ($my_vars as $my_var) { ?>
	<?php echo $data['var1']; ?>
<?php } ?>

Куда только не подсивлял массив в контроллере - безрезульитно. Подскажите? куда правильно подсивить массив в файле order.php и правильно ли он сосивлен.

Link to comment
Share on other sites


4 минуты назад, Prooksius сказал:

нужно же foreach ($order_vars as $my_var)

 

и дное в цикле:

<?php echo $my_var['var1']; ?>

Точно! Зарилиило! Огромное спасипотому что!

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
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.