From 828324382393aa3b2fcc9bf6c545ab683a5102f5 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 22 Jun 2010 08:27:38 -0700 Subject: [PATCH] Allow visitor to remove items from their cart. Fixes bug #11667 --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Shop/Cart.pm | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 79cb309a7..35e048fcc 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -6,6 +6,7 @@ - fixed #11628: Message Board: Last Post doesn't show up in CS Thread List - fixed #11646: Post and Thread Last Post - fixed #11626: Duplicate messages from Collab Systems + - fixed #11667: Shop: unable to remove item from Cart 7.9.7 - added #11571: Allow return from photo edit view to gallery edit view diff --git a/lib/WebGUI/Shop/Cart.pm b/lib/WebGUI/Shop/Cart.pm index 5b2afe4f5..67bae3530 100644 --- a/lib/WebGUI/Shop/Cart.pm +++ b/lib/WebGUI/Shop/Cart.pm @@ -762,6 +762,15 @@ sub updateFromForm { $error{id $self} = $i18n->get('mixed items warning'); } + my @cartItemIds = $form->process('remove_item', 'checkList'); + foreach my $cartItemId (@cartItemIds) { + my $item = eval { $self->getItem($cartItemId); }; + $item->remove if ! Exception::Class->caught(); + } + + ##Visitor cannot have an address book, or set a payment gateway, so skip the rest of this. + return 1 if $session->user->isVisitor; + my $book = $self->getAddressBook; my $cartProperties = {}; @@ -825,12 +834,6 @@ sub updateFromForm { $cartProperties->{ shipperId } = $form->process( 'shipperId' ) if $form->process( 'shipperId' ); $cartProperties->{ gatewayId } = $form->process( 'gatewayId' ) if $form->process( 'gatewayId' ); $self->update( $cartProperties ); - - my @cartItemIds = $form->process('remove_item', 'checkList'); - foreach my $cartItemId (@cartItemIds) { - my $item = eval { $self->getItem($cartItemId); }; - $item->remove if ! Exception::Class->caught(); - } } #-------------------------------------------------------------------