Modifying a .js Function for Print [QZ Tray, WooCommerce POS]

First, I’m getting confused in the setup here. From the initial posPrintReceipt function, am I attempting to print what’s inside the newHTML variable? or something else altogether?

Yes, but the WooCommerce code appears to append the newHTML content to the existing page (as observed by the use of window.print();), likely taking advantage of a @media print style sheet.

Unfortunately, QZ Tray uses JavaFX’s WebView under the covers, (at time of writing this) incapable of honoring special @media print style sheets.

Worse, QZ Tray doesn’t really understand page origin for flavor: "plain", so all relative link, src, tags (e.g. ./style.css) must be made absolute if provided as flavor: "plain" text (rather than a URL as flavor: "file").

Third, QZ Tray has very limited multi-page support, so if anything is expected to have proper multi-page support, be prepared to have layout issues. This limitation is not present with PDF printing.

Lastly, the newHTML is an HTML Element (technically a jQuery-wrapped HTML Element) so you’d have to call newHTML.html() to append it to a JavaScript string variable.

2nd, I’m not sure if I’m laying out the data properly in HTML. So far, I’ve mainly tried the following inside one of the print chains […] so far only prints out a single [object Object] line in the final print

If using QZ Tray 2.1, it now supports multiple printers and data objects at once. This is documented best in the unit tests of the bug report that tracked this feature. This will simplify the Promise chain.

Other than the Element vs. String issue as well as the relative link|src gotchas mentioned above, the code appears to be formatted correctly for the QZ Tray API.