[Koha-patches] [PATCH] Bug 3215 - It would be nice if "Add to Cart" changed to "Remove from Cart"

Owen Leonard oleonard at myacpl.org
Mon Jan 30 16:12:59 CET 2012


"Add to Cart" links in the OPAC should reflect whether a title
is already in the Cart. On the results, list, and detail pages
the "Add to Cart" link will say "In your cart (remove)" if the
title is in your cart. The "(remove)" link will remove the title.

This patch adds a check of the biblionumbers in the cart to the
relevant scripts and sets a variable for the template governing
whether to show "Add to cart" or "In your cart."

Pages to test:

  - the search results page
  - any detail page (normal, MARC, ISBD)
  - any list contents page (/cgi-bin/koha/opac-shelves.pl?viewshelf=XX)

Situations to test:

- Add a single item to the Cart from the above pages

The link should change from "Add to cart" to "In your cart (remove)"
The count of items in your cart should reflect the addition, and the
notification box should appear.

- Remove a single item from the Cart from the above pages

The link should change from "In your cart (remove)" to "Add to cart."
The count of items in your cart should reflect the removal, and the
notification box should appear.

- View an item which is already in the cart from the above pages

The cart links should reflect whether the title is already in the cart.

- Remove one or more items from the Cart via the cart pop-up window

View the above pages as you do so to verify that the operation is
reflected immediately by the state of the "in your cart" links.

- Empty the Cart from the cart pop-up window

View the above pages as you do so to verify that the operation is
reflected immediately by the state of the "in your cart" links.

Tested in Firefox 9, Chrome 16, IE 7, and Opera 11.6 on Win 7
---
 C4/VirtualShelves/Page.pm                          |   11 ++++
 koha-tmpl/opac-tmpl/prog/en/css/opac.css           |   16 ++++++
 .../opac-tmpl/prog/en/includes/doc-head-close.inc  |    3 +
 koha-tmpl/opac-tmpl/prog/en/js/basket.js           |   58 ++++++++++++++++++--
 .../opac-tmpl/prog/en/modules/opac-ISBDdetail.tt   |   10 +++-
 .../opac-tmpl/prog/en/modules/opac-MARCdetail.tt   |   10 +++-
 koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt |    8 +++-
 .../opac-tmpl/prog/en/modules/opac-results.tt      |    8 +++-
 .../opac-tmpl/prog/en/modules/opac-shelves.tt      |    9 +++-
 opac/opac-ISBDdetail.pl                            |   11 ++++
 opac/opac-MARCdetail.pl                            |   11 ++++
 opac/opac-detail.pl                                |   11 ++++
 opac/opac-search.pl                                |   12 ++++
 13 files changed, 162 insertions(+), 16 deletions(-)

diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm
index cfa4f60..7cab246 100644
--- a/C4/VirtualShelves/Page.pm
+++ b/C4/VirtualShelves/Page.pm
@@ -68,6 +68,14 @@ sub shelfpage ($$$$$) {
     my ( $shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset );
     my $marcflavour = C4::Context->preference("marcflavour");
 
+    # get biblionumbers stored in the cart
+    my @cart_list;
+    my $cart_cookie = ( $type eq 'opac' ? "bib_list" : "intranet_bib_list" );
+    if($query->cookie($cart_cookie)){
+        my $cart_list = $query->cookie($cart_cookie);
+        @cart_list = split(/\//, $cart_list);
+    }
+
     $shelflimit = ( $type eq 'opac' ? C4::Context->preference('OPACnumSearchResults') : C4::Context->preference('numSearchResults') );
     $shelflimit = $shelflimit || 20;
     $shelfoffset   = ( $itemoff - 1 ) * $shelflimit;     # Sets the offset to begin retrieving items at
@@ -227,6 +235,9 @@ sub shelfpage ($$$$$) {
                     my @items_infos = &GetItemsLocationInfo( $this_item->{'biblionumber'});
                     $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
                     $this_item->{'ITEM_RESULTS'} = \@items_infos;
+                    if ( grep {$_ eq $biblionumber} @cart_list) {
+                        $this_item->{'incart'} = 1;
+                    }
 
                     if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnList')) {
                         $this_item->{'TagLoop'} = get_tags({
diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css
index f904af2..f2b1467 100755
--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css
+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css
@@ -453,6 +453,18 @@ a .term {
 	background-image:url(../../images/cart2.gif);
 }
 
+#action a.cartRemove, .actions a.cartRemove {
+	color: #cc3333;
+	font-size : 90%;
+	margin : 0;
+	padding: 0;
+}
+
+#action a.incart {
+	background-image:url(../../images/cart2.gif);
+	color : #666;
+}
+
 /* toolbar buttons */
 
 #toolbar {
@@ -1296,6 +1308,9 @@ padding-left : .4em;
 	color: #707070;
 	padding : 0 0 .5em 0;
 }
+.results_summary .results_summary {
+	font-size : 100%;
+}
 
 .m880 {
     display:block; 
@@ -1498,6 +1513,7 @@ div.lang{
 	box-shadow: 1px 1px 3px #666;
 	-moz-box-shadow: 1px 1px 3px #666;
 	-webkit-box-shadow: 1px 1px 3px #666;
+	z-index: 2;
 
 }
 
diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
index 18e5917..3907f34 100644
--- a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
+++ b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
@@ -48,12 +48,15 @@
     [% IF ( opacbookbag ) %]var MSG_BASKET_EMPTY = _("Your cart is currently empty");
     var MSG_RECORD_IN_BASKET = _("This item is already in your cart");
     var MSG_RECORD_ADDED = _("This item has been added to your cart");
+    var MSG_RECORD_REMOVED = _("This item has been removed from your cart");
     var MSG_NRECORDS_ADDED = _(" item(s) added to your cart");
     var MSG_NRECORDS_IN_BASKET = _("already in your cart");
     var MSG_NO_RECORD_SELECTED = _("No item was selected");
     var MSG_NO_RECORD_ADDED = _("No item was added to your cart");
     var MSG_CONFIRM_DEL_BASKET = _("Are you sure you want to empty your cart?");
     var MSG_CONFIRM_DEL_RECORDS = _("Are you sure you want to remove the selected items?");
+    var MSG_ITEM_IN_CART = _("In your cart");
+    var MSG_ITEM_NOT_IN_CART = _("Add to your cart");
 	$("#cartDetails").ready(function(){ $("#cmspan").html("<a href=\"#\" id=\"cartmenulink\" class=\"\"><i><\/i><span><i><\/i><span><\/span><span id=\"carticon\"></span> "+_("Cart")+"<span id=\"basketcount\"><\/span><\/span><\/a>"); }); [% ELSE %][% IF ( virtualshelves ) %]
     var MSG_NO_RECORD_SELECTED = _("No item was selected");[% END %][% END %]
     [% IF ( opacuserlogin ) %][% IF ( TagsEnabled ) %]var MSG_TAGS_DISABLED = _("Sorry, tags are not enabled on this system.");
diff --git a/koha-tmpl/opac-tmpl/prog/en/js/basket.js b/koha-tmpl/opac-tmpl/prog/en/js/basket.js
index c83e001..573f3b3 100644
--- a/koha-tmpl/opac-tmpl/prog/en/js/basket.js
+++ b/koha-tmpl/opac-tmpl/prog/en/js/basket.js
@@ -128,10 +128,12 @@ function addRecord(val, selection,NoMsgAlert) {
     if (write) {
         writeCookie(nameCookie, valCookie);
         if (selection) { // when adding a selection of records
+            updateLink(val,"add");
             return 1;
         }
         if (! NoMsgAlert ) {
             showCartUpdate(MSG_RECORD_ADDED);
+            updateLink(val,"add");
         }
     }
 }
@@ -229,12 +231,24 @@ function selRecord(num, status) {
     document.myform.records.value = str;
 }
 
+function delSingleRecord(biblionumber){
+    var nameCookie = "bib_list";
+    var valCookie = readCookie(nameCookie);
+    var arrayRecords = valCookie.split("/");
+    var pos = jQuery.inArray(biblionumber,arrayRecords);
+    arrayRecords.splice(pos,1);
+    valCookie = arrayRecords.join("/");
+    writeCookie( nameCookie, valCookie );
+    updateBasket( arrayRecords.length-1 );
+    updateLink(biblionumber,"del");
+    showCartUpdate(MSG_RECORD_REMOVED);
+}
+
 function delSelRecords() {
     var recordsSel = 0;
     var end = 0;
     var nameCookie = "bib_list";
     var valCookie = readCookie(nameCookie, 1);
-
     if (valCookie) {
         var str = document.myform.records.value;
         if (str.length > 0){
@@ -243,9 +257,10 @@ function delSelRecords() {
             while (!end){
                 s = str.indexOf("/");
                 if (s>0){
-                    num = str.substring(0, s)
+                    num = str.substring(0, s);
                     str = delRecord(num,str);
                     str2 = delRecord(num,str2);
+                    updateLink(num,"del",top.opener);
                 } else {
                     end = 1;
                 }
@@ -312,6 +327,7 @@ function delBasket() {
     rep = confirm(MSG_CONFIRM_DEL_BASKET);
     if (rep) {
         delCookie(nameCookie);
+        updateAllLinks(top.opener);
         document.location = "about:blank";
         updateBasket(0,top.opener);
         window.close();
@@ -383,11 +399,11 @@ function showLess() {
 
 function updateBasket(updated_value,target) {
 	if(target){
-	target.$('#basketcount').html("<span>"+updated_value+"</span>");
-	target.$('#cartDetails').html(_("Your cart contains ")+updated_value+_(" items"));
+    	target.$('#basketcount').html("<span>"+updated_value+"</span>");
+    	target.$('#cartDetails').html(_("Your cart contains ")+updated_value+_(" items"));
 	} else {
-	$('#basketcount').html("<span>"+updated_value+"</span>");
-	$('#cartDetails').html(_("Your cart contains ")+updated_value+_(" items"));
+    	$('#basketcount').html("<span>"+updated_value+"</span>");
+    	$('#cartDetails').html(_("Your cart contains ")+updated_value+_(" items"));
 	}
 	var basketcount = updated_value;
 }
@@ -458,6 +474,36 @@ function hideLists(){
     $("#listsDetails").fadeOut("fast");
 }
 
+function updateLink(val,op,target){
+    if(target){
+        if(op == "add"){
+            target.$("a.cart"+val).html(MSG_ITEM_IN_CART).addClass("incart");
+            target.$("a.cartR"+val).show();
+        } else {
+            target.$("a.cart"+val).html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart cart"+val);
+            target.$("a.cartR"+val).hide();
+        }
+    } else {
+        if(op == "add"){
+            $("a.cart"+val).html(MSG_ITEM_IN_CART).addClass("incart");
+            $("a.cartR"+val).show();
+        } else {
+            $("a.cart"+val).html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart cart"+val);
+            $("a.cartR"+val).hide();
+        }
+    }
+}
+
+function updateAllLinks(target){
+    if(target){
+        target.$("a.incart").html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart");
+        target.$("a.cartRemove").hide();
+    } else {
+        $("a.incart").html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart");
+        $("a.cartRemove").hide();
+    }
+}
+
 $("#cartDetails").ready(function(){
 	$("#cartDetails,#cartmenulink").click(function(){ hideCart(); });
 	$("#cartmenulink").click(function(){ openBasket(); return false; });
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt
index f9984a7..e954d17 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt
@@ -70,9 +70,13 @@
         </a></li>
     [% END %][% END %]
 [% END %]
-        [% IF ( opacbookbag ) %]<li><a class="addtocart" href="#" onclick="addRecord('[% biblionumber %]'); return false;">
-            Add to Your Cart
-        </a></li>[% END %]
+        [% IF ( opacbookbag ) %]
+            [% IF ( incart ) %]
+                <li><a class="incart cart[% biblionumber %]" href="#" onclick="addRecord('[% biblionumber %]'); return false;">In your cart</a> <a class="cartRemove cartR[% biblionumber %]" href="#" onclick="delSingleRecord('[% biblionumber %]'); return false;">(remove)</a></li>
+            [% ELSE %]
+                <li><a class="addtocart cart[% biblionumber %]" href="#" onclick="addRecord('[% biblionumber %]'); return false;">Add to your cart</a>  <a style="display:none;" class="cartRemove cartR[% biblionumber %]" href="#" onclick="delSingleRecord('[% biblionumber %]'); return false;">(remove)</a></li>
+            [% END %]
+        [% END %]
 		<li style="display:none;"><a href="#" id="furthersearches">More searches</a></li>
 </ul>
 
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt
index 284154e..cc716d4 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt
@@ -227,9 +227,13 @@ $(document).ready(function(){
         </a></li>
     [% END %][% END %]
 [% END %]
-        [% IF ( opacbookbag ) %]<li><a class="addtocart" href="#" onclick="addRecord('[% biblionumber %]'); return false;">
-            Add to Your Cart
-        </a></li>[% END %]
+        [% IF ( opacbookbag ) %]
+            [% IF ( incart ) %]
+                <li><a class="incart cart[% biblionumber %]" href="#" onclick="addRecord('[% biblionumber %]'); return false;">In your cart</a> <a class="cartRemove cartR[% biblionumber %]" href="#" onclick="delSingleRecord('[% biblionumber %]'); return false;">(remove)</a></li>
+            [% ELSE %]
+                <li><a class="addtocart cart[% biblionumber %]" href="#" onclick="addRecord('[% biblionumber %]'); return false;">Add to your cart</a>  <a style="display:none;" class="cartRemove cartR[% biblionumber %]" href="#" onclick="delSingleRecord('[% biblionumber %]'); return false;">(remove)</a></li>
+            [% END %]
+        [% END %]
         <li style="display:none;"><a href="#" id="furthersearches">More searches</a></li>
 </ul>
 
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
index 6e70bf9..d1a4319 100755
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
@@ -1058,7 +1058,13 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
         </a></li>
     [% END %][% END %]
 [% END %]
-        [% IF ( opacbookbag ) %]<li><a class="addtocart" href="#" onclick="addRecord('[% biblionumber %]'); return false;">Add to Your Cart</a></li>[% END %]
+        [% IF ( opacbookbag ) %]
+            [% IF ( incart ) %]
+                <li><a class="incart cart[% biblionumber %]" href="#" onclick="addRecord('[% biblionumber %]'); return false;">In your cart</a> <a class="cartRemove cartR[% biblionumber %]" href="#" onclick="delSingleRecord('[% biblionumber %]'); return false;">(remove)</a></li>
+            [% ELSE %]
+                <li><a class="addtocart cart[% biblionumber %]" href="#" onclick="addRecord('[% biblionumber %]'); return false;">Add to your cart</a>  <a style="display:none;" class="cartRemove cartR[% biblionumber %]" href="#" onclick="delSingleRecord('[% biblionumber %]'); return false;">(remove)</a></li>
+            [% END %]
+        [% END %]
 		<li style="display:none;"><a href="#" id="furthersearches">More searches</a></li>
 </ul>
 
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt
index 5359dbc..e887d8f 100755
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt
@@ -525,7 +525,13 @@ $(document).ready(function(){
 
 				[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( virtualshelves ) %]<a class="addtoshelf" href="/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]" onclick="Dopop('opac-addbybiblionumber.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]'); return false;">Save to Lists</a>
     			[% END %][% END %][% END %]
-        		[% IF ( opacbookbag ) %]<a class="addtocart" href="#" onclick="addRecord('[% SEARCH_RESULT.biblionumber %]'); return false;">Add to Cart</a>[% END %]
+                [% IF ( opacbookbag ) %]
+                    [% IF ( SEARCH_RESULT.incart ) %]
+                        <a class="addtocart cart[% SEARCH_RESULT.biblionumber %]" href="#" onclick="addRecord('[% SEARCH_RESULT.biblionumber %]'); return false;">In your Cart</a> <a class="cartRemove cartR[% SEARCH_RESULT.biblionumber %]" href="#" onclick="delSingleRecord('[% SEARCH_RESULT.biblionumber %]'); return false;">(remove)</a>
+                    [% ELSE %]
+                        <a class="addtocart cart[% SEARCH_RESULT.biblionumber %]" href="#" onclick="addRecord('[% SEARCH_RESULT.biblionumber %]'); return false;">Add to Cart</a> <a style="display:none;" class="cartRemove cartR[% SEARCH_RESULT.biblionumber %]" href="#" onclick="delSingleRecord('[% SEARCH_RESULT.biblionumber %]'); return false;">(remove)</a>
+                    [% END %]
+                [% END %]
 				</span>
 				</td><td>
 					<a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt
index 391037f..d3dc082 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt
@@ -321,8 +321,13 @@ $(function() {
 
         [% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( virtualshelves ) %]<a class="addtolist" href="/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber=[% itemsloo.biblionumber %]" onclick="Dopop('opac-addbybiblionumber.pl?biblionumber=[% itemsloo.biblionumber %]'); return false;">Save to another list</a>
           [% END %][% END %][% END %]
-
-            [% IF ( opacbookbag ) %]<a class="addtocart" href="#" onclick="addRecord('[% itemsloo.biblionumber %]'); return false;">Add to Cart</a>[% ELSE %]nocart[% END %]
+          [% IF ( opacbookbag ) %]
+              [% IF ( itemsloo.incart ) %]
+                  <a class="addtocart cart[% itemsloo.biblionumber %]" href="#" onclick="addRecord('[% itemsloo.biblionumber %]'); return false;">In your cart</a> <a class="cartRemove cartR[% itemsloo.biblionumber %]" href="#" onclick="delSingleRecord('[% itemsloo.biblionumber %]'); return false;">(remove)</a>
+              [% ELSE %]
+                  <a class="addtocart cart[% itemsloo.biblionumber %]" href="#" onclick="addRecord('[% itemsloo.biblionumber %]'); return false;">Add to Cart</a> <a style="display:none;" class="cartRemove cartR[% itemsloo.biblionumber %]" href="#" onclick="delSingleRecord('[% itemsloo.biblionumber %]'); return false;">(remove)</a>
+              [% END %]
+          [% END %]
         </span>
 
 
diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl
index c80d41c..4f373b5 100755
--- a/opac/opac-ISBDdetail.pl
+++ b/opac/opac-ISBDdetail.pl
@@ -69,6 +69,17 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 
 my $biblionumber = $query->param('biblionumber');
 
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("bib_list")){
+    my $cart_list = $query->cookie("bib_list");
+    @cart_list = split(/\//, $cart_list);
+    if ( grep {$_ eq $biblionumber} @cart_list) {
+        $template->param( incart => 1 );
+    }
+}
+
 $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
 
diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl
index f408cd2..a14815c 100755
--- a/opac/opac-MARCdetail.pl
+++ b/opac/opac-MARCdetail.pl
@@ -81,6 +81,17 @@ $template->param(
     bibliotitle => $biblio->{title},
 );
 
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("bib_list")){
+    my $cart_list = $query->cookie("bib_list");
+    @cart_list = split(/\//, $cart_list);
+    if ( grep {$_ eq $biblionumber} @cart_list) {
+        $template->param( incart => 1 );
+    }
+}
+
 $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
 
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index c4d8218..ce5d3c3 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -74,6 +74,17 @@ if ( ! $record ) {
 }
 $template->param( biblionumber => $biblionumber );
 
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("bib_list")){
+    my $cart_list = $query->cookie("bib_list");
+    @cart_list = split(/\//, $cart_list);
+    if ( grep {$_ eq $biblionumber} @cart_list) {
+        $template->param( incart => 1 );
+    }
+}
+
 
 SetUTF8Flag($record);
 
diff --git a/opac/opac-search.pl b/opac/opac-search.pl
index 08a4687..31775b0 100755
--- a/opac/opac-search.pl
+++ b/opac/opac-search.pl
@@ -88,6 +88,14 @@ if ($template_name eq 'opac-results.tmpl') {
    $template->param('COinSinOPACResults' => C4::Context->preference('COinSinOPACResults'));
 }
 
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($cgi->cookie("bib_list")){
+    my $cart_list = $cgi->cookie("bib_list");
+    @cart_list = split(/\//, $cart_list);
+}
+
 if ($format eq 'rss2' or $format eq 'opensearchdescription' or $format eq 'atom') {
     $template->param($format => 1);
     $template->param(timestamp => strftime("%Y-%m-%dT%H:%M:%S-00:00", gmtime)) if ($format eq 'atom'); 
@@ -497,6 +505,10 @@ for (my $i=0;$i<@servers;$i++) {
         # in order to avoid problems generated by the default size value in TT
         foreach my $line (@newresults) {
             if ( not exists $line->{'size'} ) { $line->{'size'} = "" }
+            # while we're checking each line, see if item is in the cart
+            if ( grep {$_ eq $line->{'biblionumber'}} @cart_list) {
+                $line->{'incart'} = 1;
+            }
         }
 
         my $tag_quantity;
-- 
1.7.3



More information about the Koha-patches mailing list