Problem/Motivation

Steps to replicate:

  • Make sure that there is no current order in point of sale
  • Go to admin/commerce/pos/main
  • Add an order item
  • Go to admin/commerce/orders
  • Select Show Receipt from operations of the draft point of sale order
  • The site breaks

I see this error in the logs:

InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 198 of /var/www/commerce-pos/web/core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Proposed resolution

Find the source of the problem and fix it.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Comments

subhojit777 created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new3.22 KB

This is because we shouldn't be able to print receipts for orders that are not yet placed.

alexpott’s picture

StatusFileSize
new3.22 KB
new3.22 KB

Here's a test and fix for what happens when the jQuery.print library is not available.

alexpott’s picture

StatusFileSize
new9.2 KB
new12.42 KB

lol forgot to commit the changes. Ignore #3.

alexpott’s picture

I've got a major concern about this code thats in commerce_pos_receipt.

  Drupal.AjaxCommands.prototype.printReceipt = function (ajax, response, status) {
    $(response.content).print({
      globalStyles: false,
      stylesheet: drupalSettings.commercePosReceipt.cssUrl,
      deferred: $.Deferred().done(function(){
        // Sloppy, should probaby be nice and scalable, but that might never be needed
        $('.commerce-pos-receipt-button-done').click();
      })
    });
  };

The code in modules/receipt/js/commerce_pos_receipt.js overrides the default submit behaviour and stops the order being completed until the receipt is printed. This feels super wrong. We should only be printing the receipt once the order has been placed and that happens when you press the button click that this is deferring. This means that if something in browser goes wrong or the user never closes the receipt screen the order is never placed.

subhojit777’s picture

Issue tags: -Needs tests
shabana.navas’s picture

Status: Needs review » Reviewed & tested by the community

Tested locally and with simplytest.me. The patch works as expected where the 'Show Receipt' option doesn't display on orders in the 'Draft' state and displays for orders in the 'Completed' state.

alexpott’s picture

Status: Reviewed & tested by the community » Postponed
Related issues: +#2935465: Receipt flow potential leaves order unplaced

Let's postpone this on #2935465: Receipt flow potential leaves order unplaced. That issue results in this one being fixed. Once that it done we should add the tests from this one.

alexpott’s picture

Status: Postponed » Reviewed & tested by the community

Actually having this in before #2935465: Receipt flow potential leaves order unplaced would make it simpler to write good tests for that one. Back to rtbc.

alexpott’s picture

  • alexpott committed 29f8458 on 8.x-2.x
    Issue #2935353 by alexpott, shabana.navas: Site error during "Show...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

I credited @shabana.navas for the review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.