Bug 3215

Summary: It would be nice if "Add to Cart" changed to "Remove from Cart"
Product: Koha Reporter: Chris Cormack <chris>
Component: OPACAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Ian Walls <koha.sekjal>
Severity: enhancement    
Priority: P5 - low CC: katrin.fischer, koha.sekjal, nengard, oleonard, paul.poulain, wizzyrea
Version: 3.8   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7466
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: [PATCH] Bug 3215 - It would be nice if "Add to Cart" changed to "Remove from Cart"
Bug 3215 - It would be nice if "Add to Cart" changed to "Remove from Cart"
Bug 3215 [REBASED] It would be nice if "Add to Cart" changed to "Remove from Cart"

Description Chris Cormack 2010-05-21 01:07:54 UTC


---- Reported by gcollum@hotmail.com 2009-05-10 00:40:44 ----

After performing a search in opac, if you click on "Add to Cart" there is feedback that you added an item to the cart, but if you are scrolled far down into your search results the feedback is not visible.

It would be nice if "Add to Cart" could change to "Remove from Cart" and that functionality was added for the given bib.  It would give the user more feedback and the ability to easily correct a mistake.



--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:07 UTC  ---

This bug was previously known as _bug_ 3215 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=3215

Actual time not defined. Setting to 0.0
The original reporter of this bug does not have
   an account here. Reassigning to the person who moved
   it here: chris@bigballofwax.co.nz.
   Previous reporter was gcollum@hotmail.com.

Comment 1 Owen Leonard 2012-01-27 17:13:41 UTC
A basic fix for this has been submitted in Bug 7466 - "Cart notification popup should appear onscreen even when button is offscreen."

I'm also working on a more complex fix, wherein each "add to cart" link becomes "In your cart (remove)" where "(remove)" is a link to remove the item from your cart. This feature will be implemented on the search results page, the list contents page (/cgi-bin/koha/opac-shelves.pl?viewshelf=XX), and the biblio detail pages.
Comment 2 Owen Leonard 2012-01-27 17:21:51 UTC
Screencast example (Flash required, sorry): http://screencast.com/t/UKQPLRyIP5
Comment 3 Owen Leonard 2012-01-30 15:14:42 UTC Comment hidden (obsolete)
Comment 4 Liz Rea 2012-02-02 21:30:01 UTC Comment hidden (obsolete)
Comment 5 Ian Walls 2012-02-06 16:06:36 UTC
Given that Perl 5.10 is now the minimum version for Koha, it may prove more efficient to use ~~ than grep.  For example:

if ( grep {$_ eq $biblionumber} @cart_list) {
   $this_item->{'incart'} = 1;
}

Becomes

if ( $biblionumber ~~ @cart_list) {
   $this_item->{'incart'} = 1;
}

Template level changes look good, and code is clean.  Just wanted to bring this up to see if anyone had more information or an opinion on the matter before I push through QA
Comment 6 Paul Poulain 2012-02-17 14:29:04 UTC
(In reply to comment #5)
> Template level changes look good, and code is clean.  Just wanted to bring this
> up to see if anyone had more information or an opinion on the matter before I
> push through QA

Not a big deal for me, marking passed QA
Comment 7 Paul Poulain 2012-02-20 15:58:53 UTC
Sorry owen, but the patches don't apply anymore
CONFLICT (content): Merge conflict in koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt
CONFLICT (content): Merge conflict in koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt
CONFLICT (content): Merge conflict in koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt

Looking at the diff, I think/suspect it's easy to fix. But as it's not trivial, I won't do it myself to avoid doing a mistake. Could you rebase & resubmit (let the "passed QA" status if it appear to be easy, i'll test it myself anyway)
Comment 8 Owen Leonard 2012-02-21 14:30:00 UTC
Created attachment 7787 [details] [review]
Bug 3215 [REBASED] It would be nice if "Add to Cart" changed to "Remove from Cart"

"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
Comment 9 Owen Leonard 2012-02-21 14:31:53 UTC
My original patch didn't apply because since I submitted it a new include was introduced for the OPAC detail pages. The rebased patch moves the changes which were originally in each of the three detail pages into the single new include.
Comment 10 Jared Camins-Esakov 2012-12-31 00:40:01 UTC
There have been no further reports of problems so I am marking this bug resolved.