From 985955e6fe86ba3eeb3095794125a35745b61d65 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 12 Jun 2018 16:05:36 -0400 Subject: [PATCH] Deduplicate selected cart items. - Fixes bug with double-counting on Combined search results. --- themes/bootstrap3/js/cart.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/themes/bootstrap3/js/cart.js b/themes/bootstrap3/js/cart.js index f5e5aeeb6a6..5f087025c8d 100644 --- a/themes/bootstrap3/js/cart.js +++ b/themes/bootstrap3/js/cart.js @@ -155,14 +155,15 @@ VuFind.register('cart', function Cart() { $("#updateCart, #bottom_updateCart").unbind('click').click(function cartUpdate() { var elId = this.id; var selected = []; + var addToSelected = function processCartFormValues() { + if (-1 === selected.indexOf(this.value)) { + selected.push(this.value); + } + }; var selectedInForm = $form.find('input[name="ids[]"]:checked'); var selectedFormAttr = $('input[form="' + $form.attr('id') + '"][name="ids[]"]:checked'); - $(selectedInForm).each(function cartFormCheckboxValues() { - selected.push(this.value); - }); - $(selectedFormAttr).each(function cartAttrCheckboxValues() { - selected.push(this.value); - }); + $(selectedInForm).each(addToSelected); + $(selectedFormAttr).each(addToSelected); if (selected.length > 0) { var msg = ""; var orig = getFullItems(); -- GitLab