Bug 36868: (follow-up) Fix deletion when nothing is in the cart, and make DB update better
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
fac6a1adfe
commit
9b5f75a79e
|
|
@ -8,14 +8,21 @@ return {
|
|||
my ($args) = @_;
|
||||
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
||||
|
||||
# Do your stuff here
|
||||
my $exists = $dbh->selectrow_array(
|
||||
q{SELECT 1 FROM systempreferences WHERE variable = 'AutoDeleteFromCartWhenHoldPlaced'});
|
||||
|
||||
if ($exists) {
|
||||
say_warning( $out, "System preference 'AutoDeleteFromCartWhenHoldPlaced' already exists, skipping" );
|
||||
return;
|
||||
}
|
||||
|
||||
$dbh->do(
|
||||
q{
|
||||
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
|
||||
('AutoDeleteFromCartWhenHoldPlaced', '','', 'Automatically delete items from cart when a hold is placed','Choice')
|
||||
}
|
||||
);
|
||||
say_success( $out, "Added new system preference 'AutoDeleteFromCartWhenHoldPlaced'" );
|
||||
|
||||
say $out "Added new system preference 'AutoDeleteFromCartWhenHoldPlaced'";
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -269,6 +269,12 @@ function delSingleRecord(biblionumber) {
|
|||
var valCookie = readCookie(nameCookie);
|
||||
var arrayRecords = valCookie.split("/");
|
||||
var pos = jQuery.inArray(biblionumber, arrayRecords);
|
||||
|
||||
// the cart is empty, bail
|
||||
if (pos <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
arrayRecords.splice(pos, 1);
|
||||
valCookie = arrayRecords.join("/");
|
||||
writeCookie(nameCookie, valCookie);
|
||||
|
|
|
|||
|
|
@ -235,6 +235,12 @@ function delSingleRecord(biblionumber) {
|
|||
var arrayRecords = valCookie.split("/");
|
||||
var pos = jQuery.inArray(biblionumber, arrayRecords);
|
||||
arrayRecords.splice(pos, 1);
|
||||
|
||||
//if cart is empty, bail
|
||||
if (pos <= -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
valCookie = arrayRecords.join("/");
|
||||
writeCookie(nameCookie, valCookie);
|
||||
updateBasket(arrayRecords.length - 1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue