OXID Community Forum

> International Forums > Developers > Save cart into cookies or database, if the user is not logged in
Login
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Thread: Save cart into cookies or database, if the user is not logged in


Reply
 
Thread Tools Display Modes
#Top   #1  
Old 02-13-2012, 06:55 AM
v_h v_h is offline
Junior Member
Join Date: Apr 2011
Posts: 12
v_h is on a distinguished road
Default Save cart into cookies or database, if the user is not logged in

Hi!
I want to keep cookies for the baskets a few days.
I am using the parameters in the file ini.php:
session.cookie_lifetime 864000
session.gc_maxlifetime 172800
session.use_cookies On On
session.use_only_cookies Off
session.use_trans_sid 1

When I put the product to cart, I have cookies "sid" and "sid_key". Cookie "sid_key" disappears, if you close your browser. And the basket disappears too, if the user is not logged in.
I look at the file oxbasket.php.
Functions:
PHP Code:
    protected function _save()
    {
        if ( 
$this->_canSaveBasket() ) {

            if ( 
$oUser $this->getBasketUser() ) {
                
//first delete all contents
                //#2039
                
$oSavedBasket $oUser->getBasket'savedbasket' );
                
$oSavedBasket->delete();

                
//then save
                
foreach ( $this->_aBasketContents as $oBasketItem ) {
                    
// discount or bundled products will be added automatically if available
                    
if ( !$oBasketItem->isBundle() && !$oBasketItem->isDiscountArticle() ) {
                       
$oSavedBasket->addItemToBasket$oBasketItem->getProductId(), $oBasketItem->getAmount(), $oBasketItem->getSelList(), true$oBasketItem->getPersParams() );
                    }
                }
            }
        }
    } 
PHP Code:
    public function deleteBasket()
    {
        
$this->_aBasketContents = array();
        
$this->getSession()->delBasket();

        if (
$this->getConfig()->getConfigParam'blPsBasketReservationEnabled' )) {
            
$this->getSession()->getBasketReservations()->discardReservations();
        }

        
// merging basket history
        
if ( !$this->getConfig()->getConfigParam'blPerfNoBasketSaving' ) ) {
            
$this->_deleteSavedBasket();
        }
    } 
I want to keep cart in cookies or a database, if the user is not logged in. How can I do this?
Thank you!
Reply With Quote
#Top   #2  
Old 02-29-2012, 06:34 AM
v_h v_h is offline
Junior Member
Join Date: Apr 2011
Posts: 12
v_h is on a distinguished road
Default Re: Save cart into cookies or database, if the user is not logged in

Hi, friends!
I did it.
I have for a lifetime of cookies sid_key:
File oxsession.php:
PHP Code:
//if we have no cookie then try to set it
if ( !$sCookieSid ) {
            
oxUtilsServer::getInstance()->setOxCookie'sid_key''oxid'time()+15724800 );

I also disabled the checkbox "Don't save Shopping Carts of registered Users" and cleared the field in the database oxuserbasketitems and oxuserbaskets.
P.S.This is my experiment! This is not a recommendation!
Reply With Quote
#Top   #3  
Old 02-29-2012, 08:47 AM
Marco Steinhaeuser's Avatar
Marco Steinhaeuser Marco Steinhaeuser is online now
Community Guide @ OXID
Join Date: Oct 2008
Posts: 10,864
Marco Steinhaeuser is on a distinguished road
Default Re: Save cart into cookies or database, if the user is not logged in

Thanks for letting us know!
__________________
Marco
http://about.me/marco.steinhaeuser

Will ignore unsolicited support requests via PM, email or IM.
Reply With Quote
Reply

Bookmarks

Tags
cart, cookies, database, logged, save, user

« Previous Thread | Next Thread »
Thread Tools
Display Modes

Nicht Sichtbar
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging in to a user account with the user's eMail-address and master admin's password avenger Modules 10 03-17-2014 09:16 AM
OXID 4.5.0 Can't create views. Please check your database user privileges. jerome Installation and configuration 3 05-12-2011 03:19 PM
save cart, different price levels, favourits, sorting Ed General 4 11-08-2010 10:17 AM
B2B Setup - Hiding Prices until logged in? bsx2010 Newbies 1 02-12-2010 07:37 AM
Abfrage Logged in / eingeloggt bleiben racoon Entwickler 4 09-05-2009 03:56 PM

All times are GMT +1. The time now is 02:59 AM.