From 827565c22af20bdcc8e93e76b7b6d05946864044 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 22 Apr 2010 13:31:10 -0700 Subject: [PATCH] Prevent redundant display of the address in the cart, unless it's separate from the per cart address. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Shop/Cart.pm | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 16e0043aa..82c18dfc1 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,6 +1,7 @@ 7.9.4 - fixed #11535: i18n - Asset_MapPoint - Tag form_fax - wrong text - Implement hierarchial keywords differently. + - fixed Redundant per item address display in cart. 7.9.3 - added #11477: No synopsis in asset now means no synopsis in search index diff --git a/lib/WebGUI/Shop/Cart.pm b/lib/WebGUI/Shop/Cart.pm index 5c9b2b0b9..3654a5417 100644 --- a/lib/WebGUI/Shop/Cart.pm +++ b/lib/WebGUI/Shop/Cart.pm @@ -776,7 +776,14 @@ sub www_view { my $template = WebGUI::Asset::Template->new($session, $session->setting->get("shopCartTemplateId")); return $session->style->userStyle($template->process(\%var)); } - + + # get the shipping address + my $address = eval { $self->getShippingAddress }; + if (my $e = WebGUI::Error->caught("WebGUI::Error::ObjectNotFound")) { + # choose another address cuz we've got a problem + $self->update({shippingAddressId=>''}); + } + # generate template variables for the items in the cart foreach my $item (@cartItems) { my $sku = $item->getSku; @@ -794,9 +801,12 @@ sub www_view { shipToButton => WebGUI::Form::submit($session, {value=>$i18n->get("ship to button"), extras=>q|onclick="setCallbackForAddressChooser(this.form,'|.$item->getId.q|');"|}), ); - my $address = eval {$item->getShippingAddress}; - unless (WebGUI::Error->caught) { - $properties{shippingAddress} = $address->getHtmlFormatted; + my $itemAddress = eval {$item->getShippingAddress}; + if ((!WebGUI::Error->caught) && $itemAddress && $address && $itemAddress->getId ne $address->getId) { + $properties{shippingAddress} = $itemAddress->getHtmlFormatted; + } + else { + $properties{shippingAddress} = ''; } $taxDriver->appendCartItemVars( \%properties, $item ); @@ -828,21 +838,13 @@ sub www_view { , ); - # get the shipping address - my $address = eval { $self->getShippingAddress }; - if (my $e = WebGUI::Error->caught("WebGUI::Error::ObjectNotFound")) { - # choose another address cuz we've got a problem - $self->update({shippingAddressId=>''}); - - } - # if there is no shipping address we can't check out if (WebGUI::Error->caught) { $var{shippingPrice} = $var{tax} = $self->formatCurrency(0); } - + # if there is a shipping address calculate tax and shipping options - else { + if ($address) { $var{hasShippingAddress} = 1; $var{shippingAddress} = $address->getHtmlFormatted; my $ship = WebGUI::Shop::Ship->new($self->session);