From 6e97455afbe6c97a1983292a16173f7613ad692a Mon Sep 17 00:00:00 2001 From: Kaleb Murphy Date: Fri, 18 Jul 2008 16:11:21 +0000 Subject: [PATCH] Product.pm no longer caches if a cart object has been created for this session. --- docs/changelog/7.x.x.txt | 2 +- etc/WebGUI.conf.original | 1 + lib/WebGUI/Asset/Sku/Product.pm | 4 ++-- lib/WebGUI/Shop/Cart.pm | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 00aecc83c..1f7fe5b9b 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,5 @@ 7.5.18 - + - fixed: Product no longer shows "Continue Shopping" view when a different user adds the Product to their Cart. The issue was the Product cached itself when an item was added to the cart. Now it checks for if a cart asset exists for this session. 7.5.17 - fixed: Payment Methods Hover Help Incomplete - fixed: Payment Method Titles Don't Match Buttons diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 2ffa0ab9a..aea993b98 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -349,6 +349,7 @@ # Specify the list of macros you wish to be processed on each page. "macros" : { + "SessionId" : "SessionId", "@" : "At_username", "#" : "Hash_userId", "/" : "Slash_gatewayUrl", diff --git a/lib/WebGUI/Asset/Sku/Product.pm b/lib/WebGUI/Asset/Sku/Product.pm index 40570d854..a63d47d3b 100644 --- a/lib/WebGUI/Asset/Sku/Product.pm +++ b/lib/WebGUI/Asset/Sku/Product.pm @@ -1392,7 +1392,7 @@ sub view { my $self = shift; my $error = shift; my $session = $self->session; - if (!$session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + if (!$session->var->isAdminOn && $self->get("cacheTimeout") > 10){ my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; return $out if $out; } @@ -1588,7 +1588,7 @@ sub view { $var{continueShoppingUrl} = $self->getUrl; my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); - if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && $self->{_hasAddedToCart} != 1){ WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout")); } return $out; diff --git a/lib/WebGUI/Shop/Cart.pm b/lib/WebGUI/Shop/Cart.pm index cf9a7d727..f7e1e97dd 100644 --- a/lib/WebGUI/Shop/Cart.pm +++ b/lib/WebGUI/Shop/Cart.pm @@ -35,7 +35,7 @@ These subroutines are available from this package: =cut readonly session => my %session; -private properties => my %properties; +public properties => my %properties; private error => my %error; private itemCache => my %itemCache; private addressBookCache => my %addressBookCache; @@ -454,7 +454,7 @@ sub newBySession { WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error=>"Need a session."); } my $cartId = $session->db->quickScalar("select cartId from cart where sessionId=?",[$session->getId]); - return $class->new($session, $cartId) if (defined $cartId); + return $class->new($session, $cartId) if (defined $cartId and $cartId ne ''); return $class->create($session); }