PrintButton.php in Ubercart 8.4
File
uc_order/src/Plugin/Ubercart/OrderPane/PrintButton.php
View source
<?php
namespace Drupal\uc_order\Plugin\Ubercart\OrderPane;
use Drupal\Core\Url;
use Drupal\uc_order\OrderInterface;
use Drupal\uc_order\OrderPanePluginBase;
class PrintButton extends OrderPanePluginBase {
public function getTitle() {
return '';
}
public function view(OrderInterface $order, $view_mode) {
if ($view_mode == 'customer' && $order
->access('invoice')) {
$build = [
'#type' => 'link',
'#title' => $this
->t('Click to open a window with a printable invoice.'),
'#url' => Url::fromRoute('uc_order.user_invoice_print', [
'user' => $order
->getOwnerId(),
'uc_order' => $order
->id(),
], [
'attributes' => [
'onclick' => "window.open(this.href, '" . $this
->t('Invoice') . "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=480,left=50,top=50'); return false;",
],
]),
];
return $build;
}
}
}