Koha How-To

Show Library Cost Savings on your Koha Receipt

How To

Want to show your patrons what they saved by using your library? This handy tutorial will walk you through the steps to add it to the receipts your library prints with Koha.

First, you want to log in to your Koha staff client and go to Tools > Notices & Slips.

Next, you’ll want to find your ISSUESLIP or ISSUEQSLIP (or both). Although these receipts are generally printed with a receipt printer, you will want to edit the EMAIL portion of the notice, not the PRINT.

Editing Your Notice/s


You will want to add the following line inside of the <checkedout> tags:

<span class="price" style="display: none;"><<items.replacementprice>></span>

Next you will want to add the following JavaScript at the very bottom of your slip:

<script type="text/javascript">

var x = document.getElementsByClassName("price");

var i;

var total = 0;

for (i = 0; i < x.length; i++) {

var cost = parseFloat( x[i].innerHTML );

if ( ! isNaN( cost ) ) {

total += cost;

}

}

document.getElementById("price").innerHTML = total.toFixed(2);

</script>

Finally you will want to add the part that will display on your slip:

<p>

<b>You Saved</b><br/>

$<span id="price"></span><br/>

By using your library today!<br/>

</p>

You should add this part in the section where you would like it to display! Remember, this is dependent on replacement price being set for each checked out item.

TEMPLATE TOOLKIT METHOD: (v18.11+)

There is also a way to set up this feature using Template Toolkit. This will require at least Koha version 18.11 or higher. In this case, if there is no replacement price set it will look and see if there is a default replacement cost set for that item type and use that instead.

Add the following Template Toolkit somewhere near the top of your slip:

[% USE ItemTypes %]

[% SET itemtypes = ItemTypes.Get %]

[% FOREACH checkout IN checkouts %]

[% replacement = (checkout.item.replacementprice) %]

[% IF replacement == "0.00" || replacement == "" || replacement == NULL %]

[% SET my_itemtype = "" %]

[% FOREACH i IN itemtypes %]

[% IF i.itemtype == checkout.item.effective_itemtype %]

[% SET my_itemtype = i %]

[% replacement = my_itemtype.defaultreplacecost %]

[% END %]

[% END %]

[% END %]

<span class="price" style="display:none;">[% replacement %]</span>

[% END %]

At the bottom of the slip at the JavaScript:

<script type="text/javascript">

var x = document.getElementsByClassName("price");

var i;

var total = 0;

for (i = 0; i < x.length; i++) {

var cost = parseFloat( x[i].innerHTML );

if ( ! isNaN( cost ) ) {

total += cost;

}

}

document.getElementById("price").innerHTML = total.toFixed(2);

</script>

Finally you will want to add the part that will display on your slip:

<p>

<b>You Saved</b><br/>

$<span id="price"></span><br/>

By using your library today!<br/>

</p>

You should add this part in the section where you would like it to display!

Example of Entire Issue Slip

Here is a link to a document that provides an entire issue slip code if you would prefer to just copy this and input it into Koha.

Issue Slip Printed

Want more Koha How-To blog posts? Click here.