diff --git a/modules/receipt/src/Controller/PrintController.php b/modules/receipt/src/Controller/PrintController.php index a774c4b..badc131 100644 --- a/modules/receipt/src/Controller/PrintController.php +++ b/modules/receipt/src/Controller/PrintController.php @@ -10,9 +10,7 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\HtmlCommand; use Drupal\Core\Ajax\SettingsCommand; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Url; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Class PrintController. @@ -20,32 +18,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; class PrintController extends ControllerBase { /** - * The date formatter. - * - * @var \Drupal\Core\Datetime\DateFormatterInterface - */ - protected $dateFormatter; - - /** - * Creates a new PrintController object. - * - * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter - * The date formatter. - */ - public function __construct(DateFormatterInterface $date_formatter) { - $this->dateFormatter = $date_formatter; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('date.formatter') - ); - } - - /** * A controller callback. */ public function ajaxReceipt(OrderInterface $commerce_order, $print_or_email) { @@ -147,15 +119,11 @@ class PrintController extends ControllerBase { 'class' => ['use-ajax', 'button'], ], ]); - $order_date = $this->dateFormatter->format($commerce_order->getCompletedTime()); $config = \Drupal::config('commerce_pos_receipt.settings'); - if ($is_gift) { - $gift_order = '' . $this->t('GIFT ORDER') . ''; - } $build = ['#theme' => 'commerce_pos_receipt']; $build['#receipt'] = [ 'header' => [ - '#markup' => check_markup($config->get('header'), $config->get('header_format')) . "
$order_date
Order# {$commerce_order->id()}
$gift_order
", + '#markup' => check_markup($config->get('header'), $config->get('header_format')), ], 'body' => [ '#type' => 'table', diff --git a/modules/receipt/templates/commerce-pos-receipt.html.twig b/modules/receipt/templates/commerce-pos-receipt.html.twig index eb696de..5f5a62c 100644 --- a/modules/receipt/templates/commerce-pos-receipt.html.twig +++ b/modules/receipt/templates/commerce-pos-receipt.html.twig @@ -17,10 +17,13 @@
{{ receipt.print }} {% if receipt.is_gift == true %} +
{{ order.getCompletedTime|format_date() }}
+ {% trans %}Order# {{ order.id|placeholder }}{% endtrans %} +
{{ 'GIFT ORDER'|t }}
{% endif %}
{{ receipt.header }}
{{ receipt.body }}
-
+