Jump to content

Company Name In Order History Table


ICT-LabS

Recommended Posts

Hello comunity, this is my first topic.

 

I am using Prestashop 1.6 and I need to get the company name of delivery address in order history view (in one of the column).

 

I can easily get the address id but how to get the name of company?

 

i search in controller and class to add the variable company, somethingh like:

 

$address = new Adress($order.id_address_delivery)

$company=$address->company

 

but i am lost.

 

Can anyone help me or suggest for a solution?

 

Thank you

Link to comment
Share on other sites

Hello,

 

First off all you must override controllers/front/HistoryController.php. Search initContent() method:

	/**
	 * Assign template vars related to page content
	 * @see FrontController::initContent()
	 */
	public function initContent()
	{
		parent::initContent();

		if ($orders = Order::getCustomerOrders($this->context->customer->id))
			foreach ($orders as &$order)
			{
				$myOrder = new Order((int)$order['id_order']);
				if (Validate::isLoadedObject($myOrder))
					$order['virtual'] = $myOrder->isVirtual(false);
			}
		$this->context->smarty->assign(array(
			'orders' => $orders,
			'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'),
			'reorderingAllowed' => !(int)Configuration::get('PS_DISALLOW_HISTORY_REORDERING'),
			'slowValidation' => Tools::isSubmit('slowvalidation')
		));

		$this->setTemplate(_PS_THEME_DIR_.'history.tpl');
	}

and replace it by:

	/**
	 * Assign template vars related to page content
	 * @see FrontController::initContent()
	 */
	public function initContent()
	{
		parent::initContent();

		if ($orders = Order::getCustomerOrders($this->context->customer->id))
			foreach ($orders as &$order)
			{
				$myOrder = new Order((int)$order['id_order']);
				if (Validate::isLoadedObject($myOrder))
					$order['virtual'] = $myOrder->isVirtual(false);
                    
                                $delivery_address = new Address($order['id_address_delivery']);
                                $order['company_delivery'] = $delivery_address->company;
			}
		$this->context->smarty->assign(array(
			'orders' => $orders,
			'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'),
			'reorderingAllowed' => !(int)Configuration::get('PS_DISALLOW_HISTORY_REORDERING'),
			'slowValidation' => Tools::isSubmit('slowvalidation')
		));

		$this->setTemplate(_PS_THEME_DIR_.'history.tpl');
	}

Now you've got {$order.company_delivery} variable, to use in your history.tpl file.

Edited by REGE (see edit history)
Link to comment
Share on other sites

  • 4 years later...

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...