commit 2c4bc66b35ec56e8c1fab71be4b06d0b7f893ab8
Author: Moshe Weitzman <weitzman@tejasa.com>
Date:   Thu Oct 12 13:57:07 2017 -0400

    WIP

diff --git a/commerce_pos.libraries.yml b/commerce_pos.libraries.yml
index d4c1864..8469e7c 100644
--- a/commerce_pos.libraries.yml
+++ b/commerce_pos.libraries.yml
@@ -2,4 +2,13 @@ form:
   version: VERSION
   css:
     layout:
-      css/commerce_pos.module.css: {}
\ No newline at end of file
+      css/commerce_pos.module.css: {}
+jQuery.print:
+  remote: https://github.com/DoersGuild/jQuery.print
+  version: 1.5.1
+  license:
+    name: CC BY 3.0
+    url: https://github.com/DoersGuild/jQuery.print/blob/master/LICENSE
+    gpl-compatible: no
+  js:
+    /libraries/jQuery.print/jQuery.print.js: {}
diff --git a/modules/receipt/README.md b/modules/receipt/README.md
new file mode 100644
index 0000000..14e9362
--- /dev/null
+++ b/modules/receipt/README.md
@@ -0,0 +1,40 @@
+The receipt submodule provides for receipt printing. It depends on the jQuery plugin receipt-print.
+
+### Install using Composer (recommended)
+
+If you use Composer to manage dependencies, edit `/composer.json` as follows.
+
+1\. Run `composer require --prefer-dist composer/installers` to ensure that you have the `composer/installers` package installed. This package facilitates the installation of packages into directories other than `/vendor` (e.g. `/libraries`) using Composer.
+
+2\. Add the following to the "installer-paths" section of `composer.json`:
+
+```
+"libraries/{$name}": ["type:drupal-library"],
+```
+
+3\. Add the following to the "repositories" section of `composer.json`:
+
+```
+"jQuery.print": {
+    "type": "package",
+    "package": {
+        "name": "DoersGuild/jQuery.print",
+        "version": "1.5.1",
+        "type": "drupal-library",
+        "dist": {
+            "url": "https://github.com/DoersGuild/jQuery.print/archive/1.5.1.zip",
+            "type": "zip"
+        }
+    }
+},
+```
+4\. Run `composer require --prefer-dist DoersGuild/jQuery.print:1.5.*` - you should find that a new directory created
+under `/libraries`
+
+### Install manually
+
+  - Create a `/libraries/jQuery.print/` directory below your Drupal root directory
+  - Download https://raw.githubusercontent.com/DoersGuild/jQuery.print/1.5.1/jQuery.print.js
+  - Rename it to `/libraries/jQuery.print/jQuery.print.js`
+
+  For further details on how to obtain jQuery.print.js, see https://github.com/DoersGuild/jQuery.print
diff --git a/modules/receipt/commerce_pos_receipt.module b/modules/receipt/commerce_pos_receipt.module
index 856f5af..13b122f 100644
--- a/modules/receipt/commerce_pos_receipt.module
+++ b/modules/receipt/commerce_pos_receipt.module
@@ -6,6 +6,7 @@
  */
 
 use Drupal\commerce_price\Entity\Currency;
+use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\Core\Url;
 
@@ -18,7 +19,7 @@ function commerce_pos_receipt_help($route_name, RouteMatchInterface $route_match
     case 'help.page.commerce_pos_receipt':
       $output = '';
       $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('Provides receipts printing for Commerce Point of Sale') . '</p>';
+      $output .= '<p>' . t('Provides receipt printing for Commerce Point of Sale') . '</p>';
       return $output;
 
       // TODO we have an empty default here, remove?
@@ -44,17 +45,9 @@ function commerce_pos_receipt_preprocess_commerce_pos_receipt(&$variables) {
   /* @var \Drupal\commerce_payment\Entity\Payment $commerce_payment */
   $commerce_payment = &$variables['commerce_payment'];
 
-  $header = Drupal::config('commerce_pos_receipt.settings')->get('header');
-
   /* @var \Drupal\commerce_order\Entity\Order $order */
   $order = $commerce_payment->getOrder();
 
-  $variables['receipt_header'] = [
-    'message' => [
-      '#markup' => check_markup($header['value'], $header['format']),
-    ],
-  ];
-
   $number_formatter_factory = \Drupal::service('commerce_price.number_formatter_factory');
   $number_formatter = $number_formatter_factory->createInstance();
 
@@ -62,6 +55,11 @@ function commerce_pos_receipt_preprocess_commerce_pos_receipt(&$variables) {
   $currency = Currency::load($sub_total_price->getCurrencyCode());
   $formatted_amount = $number_formatter->formatCurrency($sub_total_price->getNumber(), $currency);
 
+  $items = $order->getItems();
+  foreach ($items as $item) {
+    $totals[] = [$item->getTitle(), $item->getAdjustedTotalPrice()];
+  }
+
   $totals[] = ['Subtotal', $formatted_amount];
 
   // Commerce appears to have a bug where if not adjustments exist, it will return a
@@ -86,29 +84,30 @@ function commerce_pos_receipt_preprocess_commerce_pos_receipt(&$variables) {
 
   $totals[] = ['Total', $formatted_amount];
 
-  $render = [
-    '#type' => 'table',
-    '#rows' => $totals,
-  ];
-
-  $renderer = \Drupal::service('renderer');
-  $variables['receipt_body'] = $renderer->render($render);
-
+  $header = Drupal::config('commerce_pos_receipt.settings')->get('header');
   $footer = Drupal::config('commerce_pos_receipt.settings')->get('footer');
 
-  $variables['receipt_footer'] = [
-    'message' => [
+  $variables['receipt'] = [
+    'header' => [
+      '#markup' => check_markup($header['value'], $header['format']),
+    ],
+    'body' => [
+      '#type' => 'table',
+      '#rows' => $totals,
+    ],
+    'footer' => [
       '#markup' => check_markup($footer['value'], $footer['format']),
     ],
   ];
 
+
   //$variables['#attached']['library'][] = 'commerce/pos-receipt';
 }
 
 /**
  * Implements hook_form_FORM_ID_alter
  */
-function commerce_pos_receipt_form_commerce_pos_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
+function commerce_pos_receipt_form_commerce_pos_alter(&$form, FormStateInterface $form_state, $form_id) {
   $form['receipt'] = [
     '#type' => 'container'
   ];
diff --git a/modules/receipt/templates/commerce-pos-receipt.html.twig b/modules/receipt/templates/commerce-pos-receipt.html.twig
index 1efa2bc..f6a40c7 100644
--- a/modules/receipt/templates/commerce-pos-receipt.html.twig
+++ b/modules/receipt/templates/commerce-pos-receipt.html.twig
@@ -1,6 +1,18 @@
+{#
+/**
+* @file
+* Receipt document.
+*
+* Available variables:
+* - receipt: The receipt.
+*
+* @ingroup themeable
+*/
+#}
+
 {{ attach_library('commerce_pos_receipt/receipt') }}
 <div class="commerce-pos-receipt">
-    <div class="receipt-header">{{ receipt_header }}</div>
-    <div class="receipt-body">{{ receipt_body }}</div>
-    <div class="receipt-footer">{{ receipt_footer }}</div>
+    <div class="receipt-header">{{ receipt.header }}</div>
+    <div class="receipt-body">{{ receipt.body }}</div>
+    <div class="receipt-footer">{{ receipt.footer }}</div>
 </div>
