[wellwell/interchange6: 4/5] Create the cart if not exists when restoring it

Stefan Hornburg <[email protected]> Fri, 03 Mar 2017 07:53:34 +0000
Newsgroups gmane.comp.web.interchange.cvs
Message-ID <[email protected]>
commit 110b66d7b7d7545f33f1d9fb3d1cefae6843c12e
Author: Marco Pessotto <[email protected]>
Date:   Mon Nov 25 09:26:37 2013 +0100

    Create the cart if not exists when restoring it
    
    When we restore the cart, we move the cart in the session, if it exists, into
    the database cart. But the function returns if get_cart_by_name doesn't get a
    cart, and no takeover is done. The user's cart is by no means guaranteed to be
    present, so it has to be created.

 lib/WellWell/DatabaseCart.pm |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/lib/WellWell/DatabaseCart.pm b/lib/WellWell/DatabaseCart.pm
index 26b3776..cac19b2 100644
--- a/lib/WellWell/DatabaseCart.pm
+++ b/lib/WellWell/DatabaseCart.pm
@@ -61,7 +61,7 @@ sub cart_restore {
 	my $cart;
 
     my $uid = $Vend::Session->{username} || $Vend::Session->{id};
-	$cart = get_cart_by_name($Vend::Cfg->{DatabaseCart}, 'cart', $uid);
+	$cart = get_cart_by_name($Vend::Cfg->{DatabaseCart}, 'cart', $uid, 1);
 
 	if ($cart) {
 		$cart->restore();