Problem/Motivation

#2901030: Receipt Printing added a new commerce_pos_receipt module which overrides the default behaviour to allow a receipt to be printed as part of the order flow. It uses JavaScript to inject itself in between clicking the complete order button and the regular form submit handler. This behaviour is attached by modules/receipt/js/commerce_pos_receipt.js. The problem is that this prevents the order by placed until the receipt is printed. This is not quite the right behaviour has the order should be placed before the receipt is printed. This way regardless of what happens to the browser at that point the order is in the correct state.

Proposed resolution

Discussed with @smccabe and decided to explore whether or not we could add a redirect so the order can be completed before printing the receipt and then the order can be printed from that page.

Remaining tasks

User interface changes

t.b.d.

API changes

t.b.d.

Data model changes

None

CommentFileSizeAuthor
#8 2935465-8.patch32.99 KBalexpott
#6 2935465-6.patch40.39 KBalexpott
#3 2935465-3.patch25.53 KBalexpott

Comments

alexpott created an issue. See original summary.

shabana.navas’s picture

I would definitely welcome this change as well. The workflow just seemed odd. The order should be completed on submit right away and any other steps like printing receipts should come after. Maybe add a subsequent submit handler to redirect and invoke the printing of the receipt.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new25.53 KB

Here's some work that decouples printing the receipt from completing the order. It also separates emailing from printing and generally splits up the code into different units.

I'm going to add a test based on the existing javascript test for the emailing a receipt pathway as that should no longer use the jquery library - or atleast it won't when I'm done.

Status: Needs review » Needs work

The last submitted patch, 3: 2935465-3.patch, failed testing. View results

alexpott’s picture

Priority: Major » Critical

Given this could lead to a user thinking an order has been completed when it hasn't I think this is critical and should block the next alpha / beta release.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new40.39 KB

So here are some tests for the receipt functionality. They revealed that atm we'd be sending two email receipts to the customer because we're not disabling the sendReceipt option for the pos order type! Tests ftw.

The patch attached is built on top of #2935353: Site error during "Show receipt" operation. Given the test changes that issue makes I think it should go in first. No interdiff ... because that'd be a mess.

Status: Needs review » Needs work

The last submitted patch, 6: 2935465-6.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new32.99 KB

The blocker has landed so now we can have a smaller and simpler patch.

One thought is that should we be overriding commerce's receipt email in this way? Would it be better to decorate the event listener and work with that. It is tricky because the receipt from POS is probably very different from what a receipt generated from an online transaction should look like.

smccabe’s picture

Status: Needs review » Postponed (maintainer needs more info)

After talking with Alex and Bojan, it looks like we'll likely add a change into Commerce core to facilitate this easier. That still needs to be confirmed, but is currently the most likely option.