Add button after email/invoice/shipping invoice

  • Posts: 5
  • Thank you received: 0
8 years 4 months ago #244447

-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.5.1
-- PHP version -- : 5.6.22-0+deb8u1
-- Browser(s) name and version -- : Firefox

Is there an easy way to add a new button at the backend in toolbar after the default email/invoice/shipping invoice buttons on the order view page?

I would like to set up a third document for printing (in addition to invoice and shipping invoice).

Would the third document be customisable through the Views section?

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
8 years 4 months ago #244461

Hi,

Adding a button in the toolbar can be done by creating a small plugin of the group HikaShop implementing the onHikashopBeforeDisplayView function trigger, with something like that:

function onHikashopBeforeDisplayView(&$view){
if($view->ctrl != 'product' || $view->task != 'show') return;
$this->toolbar[] = array('name' => 'Popup', 'icon' => 'send', 'id' => 'send', 'alt' => JText::_('HIKA_EMAIL'), 'url' => 'index.php?option=com_hikashop&ctrl=order&task=invoice&tmpl=component&type=full&order_id='.$order_id.'&custom=1', 'width' => 720);
}
This will also open a popup with the same content as the one when you click on "invoice" but with an extra parameter "custom" set to 1.
So then, you can edit the file "invoice" of the view "order" via the menu Display>Views and use such check in there to have your custom text for that new button:
if(@$_GET['custom']){
// echo my popup content
}else{
// echo when it's an invoice
}

The following user(s) said Thank You: dzseti

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
8 years 4 months ago #244606

I had to make some changes to the code ($view is an object from two classes and in each context its properties are different):

function onHikashopBeforeDisplayView(&$view) {
		if (get_class($view) != 'OrderViewOrder') return;
		if ($view->ctrl != 'order') return; // probably redundant
		$view->toolbar[] = array(
			'name' => 'Popup',
			'icon' => 'invoice',
			'id' => 'invoice2',
			'alt' => 'INVOICE2',
			'url' => 'index.php?option=com_hikashop&ctrl=order&task=invoice&tmpl=component&type=full&order_id=' . $view->order->order_id . '&custom=1',
			'width' => 720);
	}

Last edit: 8 years 4 months ago by dzseti. Reason: Tidying up

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum