# About Total MSRP &amp; Total Amount of save(Custom receipt)

Member Posts: 6
edited July 2018
Hello
Im struggle with getting total msrp amount .
and Trying to put on right upper of barcode
That You Saved total : (total msrp amount + promotion amount).
Im currently using default template that from official website.
Post edited by yohanJ on

• Moderator, Lightspeed Staff Posts: 654 moderator
Hey @yohanJ thank you for your question!

So the Lightspeed community can understand this question a bit better, could you draw a detailed example diagram with annotations and some examples numbers

This will help us piece what you’re saying together

Software Developer

Lightspeed HQ

• Moderator, Lightspeed Staff Posts: 654 moderator
Also is this for a label or receipt template?

Software Developer

Lightspeed HQ

• Member Posts: 6
Here it is
thank you so much!

• Moderator, Lightspeed Staff Posts: 654 moderator
@yohanJ

So as an example

Default price is \$20
MSRP is : \$45
Promotion is: \$5

so Total savings 45-20+5 = 30

Software Developer

Lightspeed HQ

• Member Posts: 6
YES!!! but not how the fomular. just sum.
• Moderator, Lightspeed Staff Posts: 654 moderator
edited July 2018
Excellent, now onto my second question, how do you give promotions in Lightspeed Retail?

is it purely using the built in discount feature or do you use price rules as well? And are there any other method of discounting/promotions you employ in the system?

Software Developer

Lightspeed HQ

• Member Posts: 6
It was made from setting -> discount -> options
• Moderator, Lightspeed Staff Posts: 654 moderator
edited August 2018
I wrote a script that would handle your request. It is explained in my code if you go line by line

You can copy the code snippet from here:
```
let str = window.location.href;
let new_num = str.replace(/[\s\S]+?([\d]+)\.html[\s\S]+/ig, "\$1");
let radPatt = /[\s\S]+\bAccount\/\b(\d{1,})[\s\S]+/ig;
let domain = window.location.host;
let thankYou =  document.querySelector('.thankyou');
credentials: "same-origin"})
.then((response) => response.json())
.then((data) => {
if (typeof data.Sale.SaleLines.SaleLine.length  == "undefined") {
let amountPaid = data.Sale.calcTotal;
let defaultPrice = data.Sale.SaleLines.SaleLine.Item.Prices.ItemPrice[0].amount;
let MSRP = data.Sale.SaleLines.SaleLine.Item.Prices.ItemPrice[1].amount;
if(amountPaid != MSRP) {
let promotion = defaultPrice - amountPaid;
let savings = MSRP - defaultPrice + promotion;
thankYou.insertAdjacentHTML('afterend', `<span style="position:absolute; left: 409px; font-size: 9pt;">YOU SAVE \$\${savings.toFixed(2)} TODAY!</span>`);
}
}
else {
let itemTotal = data.Sale.SaleLines.SaleLine;
let savings = 0
for(let i = 0; i < itemTotal.length; i++ ) {
let defaultPrice = data.Sale.SaleLines.SaleLine[i].Item.Prices.ItemPrice[0].amount;
let MSRP = data.Sale.SaleLines.SaleLine[i].Item.Prices.ItemPrice[1].amount;
let amountPaid = data.Sale.SaleLines.SaleLine[i].calcTotal;
if(amountPaid != MSRP) {
let promotion = defaultPrice - amountPaid;
savings = savings + (MSRP - defaultPrice + promotion);

}
}
thankYou.insertAdjacentHTML('afterend', `<span style="position:absolute; left: 409px; font-size: 9pt;">YOU SAVE \$\${savings.toFixed(2)} TODAY!</span>`);

}

});

});```

To add this code to your account navigate to:

Settings > Advanced Setup > Print Templates > add the code from here: https://github.com/merchantos/PrintTemplates/blob/master/receipt/SaleReceipt.tpl

Then search within the template and when you find the div HTML element below as seen, insert the script tag and paste my code in.

```<div class="receiptHeader">

*insert script tag and code like I have done below*

<script>
// Paste in the above.

</script>```

When implemented you'll get something like my screenshot below:

N.B. As Lightspeed does not support any custom template customisation, support and implementation for this request will have to be sought via third party developers and we would advise you to speak to our sales team to point you in the right direction.

Buut...if you follow my instructions, you should find this works

Have a good day @yohanJ !
Post edited by Adrian Samuel on

Software Developer

Lightspeed HQ

• Member Posts: 6
edited August 2018
Thank you sir i reallllyyy appreciate your help
and your hard work. i think i may be explain not exactly.
I'm very sorry to ask this help to you.but Please help us. Thank you

• Moderator, Lightspeed Staff Posts: 654 moderator
edited August 2018
No worries!

Good spot!

1. I didn't handle the quantities > 1, so  I've remodelled the script to take that into account now:
```document.addEventListener("DOMContentLoaded", function() {

let str = window.location.href;
let new_num = str.replace(/[\s\S]+?([\d]+)\.html[\s\S]+/ig, "\$1");
let radPatt = /[\s\S]+\bAccount\/\b(\d{1,})[\s\S]+/ig;
let domain = window.location.host;
let thankYou =  document.querySelector('.thankyou');
credentials: "same-origin"})
.then((response) => response.json())
.then((data) => {
if (typeof data.Sale.SaleLines.SaleLine.length  == "undefined") {
let amountPaid = data.Sale.calcTotal;
let defaultPrice = data.Sale.SaleLines.SaleLine.Item.Prices.ItemPrice[0].amount;
let MSRP = data.Sale.SaleLines.SaleLine.Item.Prices.ItemPrice[1].amount;
let quantity = data.Sale.SaleLines.SaleLine.unitQuantity
if((amountPaid/quantity) != MSRP || amountPaid/quantity) != defaultPrice) {
let promotion = (defaultPrice * quantity) - amountPaid;
let savings = ((MSRP - defaultPrice )* quantity ) + promotion;
thankYou.insertAdjacentHTML('afterend', `<span style="position:absolute; left: 409px; font-size: 9pt;">YOU SAVE \$\${savings.toFixed(2)} TODAY!</span>`);
}
}
else {
let itemTotal = data.Sale.SaleLines.SaleLine;
let savings = 0
for(let i = 0; i < itemTotal.length; i++ ) {
let quantity = data.Sale.SaleLines.SaleLine[i].unitQuantity;

let defaultPrice = data.Sale.SaleLines.SaleLine[i].Item.Prices.ItemPrice[0].amount;
let MSRP = data.Sale.SaleLines.SaleLine[i].Item.Prices.ItemPrice[1].amount;
let amountPaid = data.Sale.SaleLines.SaleLine[i].calcTotal;
if((amountPaid/quantity) != MSRP || amountPaid/quantity) != defaultPrice) {<br>        let promotion = (defaultPrice * quantity) - amountPaid;
savings = savings + ((MSRP - defaultPrice) * quantity) + promotion;

}
}
thankYou.insertAdjacentHTML('afterend', `<span style="position:absolute; left: 409px; font-size: 9pt;">YOU SAVE \$\${savings.toFixed(2)} TODAY!</span>`);

}

});

});```
Also, since your receipt has different content than mine, the code to handle the placement of the message will have to managed by yourself/third-party developer to align it for your receipt.

Post edited by Adrian Samuel on

Software Developer

Lightspeed HQ

• Member Posts: 6
Thank you so much for your help!!
You are such a great!

• Member Posts: 1
edited October 2018

Could this also be applied to our stores registers receipt? Please let me know if you need any specific information for our account. I was just talking to customer service(eline) and she said we could get you to change for us in our system.

• Moderator, Lightspeed Staff Posts: 654 moderator
edited November 2018
Hey @Jenelle this could, but since this custom script is not officially supported by Lightspeed,  you would need to do is apply this yourself at your own jurisdiction; I can only advise.

Place the script placed above under the following HTML

```<div class="receiptHeader">
<script>
// Paste Code here
</script>

```

Please employ the help of someone that is familiar with code to do this for you.

If any other such data such as custom fields is required, you'll need to make use of our Retail SaleTemplate API and our Item API to visualise this.

Item API) https://developers.lightspeedhq.com/retail/endpoints/Item/

Sales Receipt API) https://developers.lightspeedhq.com/retail/endpoints/DisplayTemplate-Sale/
Post edited by Adrian Samuel on

Software Developer

Lightspeed HQ

• Member Posts: 2