Stripping Work Order Notes From Sales Receipt Using the Print Template

I'm trying to remove the Work Order notes from the Sales receipt. I want like the receipt to show the Work Order number only by stripping off everything after the comma on the Work Order line. This is the line of code I'm trying. I think (hope) it may be a simple syntax error. Any suggestions?
{{ Line.Note.note|noteformat|raw"|split (',') }}
{{ Line.Note.note|noteformat|raw"|split (',') }}
39 comments
Templates vary per country so where we insert the code will differ.
However, in the Retail template, you will find the following HTML
Immediately after the above, write the code in the screenshot below (make sure to write this in a text editor)
To explain the code briefly
We are using an event listener that only executes the code inside of it once all the content on the page is loaded.
We are then selecting all the notes on the sale (since work order details appear with a .line_note class on the sale)
We are going to cycle through each of those "notes" and then get the words inside it and check if it contains the word "Work order". This ensures we are not running this code against notes that are not work orders (such as labour and miscellaneous charges).
Then we use a regular expression match the characters of the text, and we replace it with the characters up to the words am or pm.
We re-insert that replacement into the HTML containing the work order to overwrite it.
We then target the line breaks in the HTML for those work order lines and remove it dynamically.
I hope this helps!
Adrian Samuel
Software Developer
Lightspeed HQ
Here is an expanded section of the code in my Sales Receipt Template:
-----------snip-------------------------
Any suggestions?
I appreciate your help!!
Laurie
so:
<script>
//insert code
</script>
Adrian Samuel
Software Developer
Lightspeed HQ
That fixed the html code on receipt issue but I'm still getting Work Order notes on the final Sales Receipt for completed Work Orders. The Work Order notes come across as an item. What else did I do wrong?
I need the Work Order number to show on the Sales Receipt, just not the notes.
(I really appreciate you helping me. I can't use the service module until the notes are gone.)
A new screenshot can be seen below:
Adrian Samuel
Software Developer
Lightspeed HQ
Adrian Samuel
Software Developer
Lightspeed HQ
Adrian Samuel
Software Developer
Lightspeed HQ
I would suggest you make a customer feature request to better handle the messaging from the private note section from here: https://my.lightspeedpos.com/CustomerPortal_Ideas
Adrian Samuel
Software Developer
Lightspeed HQ
As to the Tax, the Workorder template API doesn't have a Tax value associated with the whole order like the Sale Template API has, so if by chance you have items that are taxed differently, it wouldn't capture it unless you wrote something programmatically. Is this the case with you, or do you always have the flat rate of 13% for all your items?
Adrian Samuel
Software Developer
Lightspeed HQ
Adrian Samuel
Software Developer
Lightspeed HQ
Regarding the tax, that is also not broken out (i.e. HST 13%) in the Work Order section of the Sales Receipt. It just says Total Tax there. Normally everything is HST 13%, but some customer's may be a special status whereby they are PST exempt so are only charged GST 5%. Either way, it would be good for this tax to be shown versus just Total Tax. Any suggestions?
Attached is a screenshot of our Sales Receipt. There you can see how the Work Order section is showing up. That line item is actually for two units (each at $1,527.00).
Adrian Samuel
Software Developer
Lightspeed HQ
Essentially, all your objects are available via the workorder template API so you'd need to basically specify the data you want.
You can access the rest of the information including the tax rate applied to line items via the same {{Workorder.WorkorderItems.WorkorderItem.SaleLine}} object
If you log in and put:
https://us.lightspeedapp.com/API/Account/{{InsertYourAccountIDHere}}/DisplayTemplate/Workorder/{{InsertWorkorderNumberHere}}.json
then you'll be able to see a json/xml view of all your data which may enable you to more effectively choose what data is useful for the workorder.
You can see how the Sales Receipt did the break-down of the receipt on line 910 through to 920
https://github.com/merchantos/PrintTemplates/blob/master/receipt/SaleReceipt.tpl.
You want to use the Twig language to assist with this. You can read more about Twig here: https://twig.symfony.com/
Adrian Samuel
Software Developer
Lightspeed HQ
Regarding the tax, that is also not broken out (i.e. HST 13%) in the Work Order section of the Sales Receipt. It just says Total Tax there. Normally everything is HST 13%, but some customer's may be a special status whereby they are PST exempt so are only charged GST 5%. Either way, it would be good for this tax to be shown versus just Total Tax. Any suggestions?
Attached is a screenshot of our Sales Receipt. There you can see how the Work Order section is showing up. That line item is actually for two units (each at $1,527.00).
Hi there,
I'm trying todo the same thing but the notes are still showing? Could someone take a look if what I'm doing is correct?
//maybe not the right place for this comment but a lack of "code insertion" in this forum/community is a bit strange? As a lot is about code it would be nice if there was a way to place code here with the right syntax and highlights?
Brunott Juwelier - vertrouwd in Rotterdam
@jonassmets . There's most likely a bug in your template. I tested my code on a fresh template and it works, but I can't get it to work for the template that you've provided. I'd say just get a fresh template from here and re-do it: https://github.com/merchantos/PrintTemplates/blob/master/receipt/SaleReceipt.tpl
Also all the new posts enable you to do code insertion, just not on old threads.
Adrian Samuel
Software Developer
Lightspeed HQ
@rishi you want to look at getting a template developer doing this for you.
Here is a link to one of our most recommended: https://www.lightspeedhq.com/ecommerce/customize/customize-advision/
Adrian Samuel
Software Developer
Lightspeed HQ
Hi @Adrian Samuel, thanks for the comment.
My template is a custom made template so I can not just use the blank one. But they only added code to change the email layout. The standard print code should not be changed. I'll check if I made a mistake in the implementation somehow.
thanks.
Jonas
Brunott Juwelier - vertrouwd in Rotterdam
Hey @jonassmets, that shouldn't make a difference. There's probably an unclosed HTML tag or twig tag that's breaking the template somewhere
Adrian Samuel
Software Developer
Lightspeed HQ
I'm going to take an other look! Thanks,
Jonas
Brunott Juwelier - vertrouwd in Rotterdam
Hi @Adrian Samuel ,
I got it working! Only thing is that the notes are still on the emailed receipt? Is there something I can do about that? Right now the "hide notes" is triggered by the print action I think?
Hope you can help me with e fix!
Kind regards,
Jonas
Brunott Juwelier - vertrouwd in Rotterdam
Hey @jonassmets,
Correct, the notes will be on the emailed receipt because all email clients strip out javascript as a matter of security so this workaround won't work for emails.
The only way around this is if you create a server-side application that takes the HTML from the Sale from Lightspeed and you strip out the information in the back-end using a server side templating language and then you send the HTML to the customer using the email client.
Adrian Samuel
Software Developer
Lightspeed HQ