WordPress.org

Support

Support » Plugins and Hacks » Shopping cart not saving items after logout

Shopping cart not saving items after logout

Viewing 13 replies - 1 through 13 (of 13 total)
  • i am having similar problem.

    i have “Keep items in cart” set to 30 days, but when user logs out and then logs in, items disappear. Can someone help?

    Plugin Author Justin Sainton

    @justinsainton

    What version of WPeC are you running?

    WP E-commerce Version 3.8.11.1

    Plugin Author Justin Sainton

    @justinsainton

    Very odd – see this screencast. http://www.zaowebdesign.com/cart_saved.swf

    It’s working fine for me. Who are you hosted with? Are you aware of any persistent object cache in place?

    I do exactly what you have in the screencast, not working. I am hosted with GoDaddy, I just made changes to php5.ini. Could that be the problem?

    Plugin Author Justin Sainton

    @justinsainton

    That could indeed be part of the issue – especially if the settings have non-standard cookie/session locations or things like that.

    Ok, I’m not very skilled at that. Below is my php5.ini file, do you have any suggestions as what to change?

    register_globals = off
    allow_url_fopen = off
    
    memory_limit = 256M
    post_max_size = 10M
    file_uploads = On
    upload_max_filesize = 10M
    max_input_vars = 2000
    
    expose_php = Off
    max_input_time = 60
    variables_order = "EGPCS"
    extension_dir = ./
    upload_tmp_dir = /tmp
    precision = 12
    SMTP = relay-hosting.secureserver.net
    url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
    
    ; Only uncomment zend optimizer lines if your application requires Zend Optimizer support
    
    ;[Zend]
    ;zend_optimizer.optimization_level=15
    ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
    ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3
    ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/ZendExtensionManager.so
    ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/ZendExtensionManager_TS.so
    
    ; -- Be very careful to not to disable a function which might be needed!
    ; -- Uncomment the following lines to increase the security of your PHP site.
    
    ;disable_functions = "highlight_file,ini_alter,ini_restore,openlog,passthru,
    ;		      phpinfo, exec, system, dl, fsockopen, set_time_limit,
    ;                     popen, proc_open, proc_nice,shell_exec,show_source,symlink"
    Plugin Author Justin Sainton

    @justinsainton

    Yeah, I’m not sure that any of those modifications would have that effect on the site.

    Did you notice this working properly before the 3.8.11.1 upgrade?

    Yes, I am also seeing that grid view is not working anymore either.

    Yes,This same prob me also have faced in my website .. But my client still want’s.
    If I log out before completing the cart purchase then it should save it for next time I log in..

    WordPress Version 3.5.1
    plugin Version 3.8.11.1

    Any Idea’s ..?
    Thanks For The Support.

    Hi,

    Has anyone been able to solve this problem?
    My shopping cart items also gets deleted when logging out and then back in

    Hi,

    I have solved the problem 🙂 In fact, I made a code that saves cart on server. Thus user can access his cart from anywhere.
    But you
    1) must be able to access your WP database,
    2) you should not to be afraid of looking at php 🙂

    Make table “custom_wp_wpsc_cart” (in your WP database) containing fields “user_ID” (bigint) and “wpsc_cart” (varchar as long as possible, for example 100000).
    Then copy this code at the begining of file plugins/wp-e-commerce/wpsc-theme/wpsc-cart_widget.php
    (If you don’t use cart widget you could try to copy this at the begining of a file you use. I just haven’t tried this code anywhere else, sorry).
    At the end of code you will find commented lines that refers to Save button – if you like to introduce one.
    Sorry if there’s something strange or needless. But it works for me 🙂

    <?php // FUNCTIONS FOR SAVING CART WITHOUT CHECKOUT ?>
    <?php
    function find_cart() {
    	global $user_ID, $wpdb;
    	$get_cart = $wpdb->get_row("SELECT * FROM custom_wp_wpsc_cart WHERE user_ID = " . $user_ID);
    	$found_cart = unserialize($get_cart->wpsc_cart);
    	return $found_cart;
    }
    
    function save_cart() {
    	global $wpsc_cart, $user_ID, $wpdb;
    	$saved_cart=serialize($wpsc_cart);
    	$is_cart=find_cart();
    	if ($is_cart) {
    		$wpdb->update('custom_wp_wpsc_cart',
    			array('wpsc_cart' => $saved_cart),
    			array( 'user_ID' => $user_ID ),
    			array('%s'),
    			array( '%d' )
    		);
    	}
    	else {
    		$wpdb->insert('custom_wp_wpsc_cart',
    			array('user_ID' => $user_ID,'wpsc_cart' => $saved_cart),
    			array('%d','%s')
    		);
    	}
    	$is_cart=find_cart();
    	return $is_cart;
    }
    
    global $wpsc_cart, $current_cart;
    if ($wpsc_cart && strpos(serialize($wpsc_cart),'sku') == false && (!isset($_POST['wpsc_ajax_action']) || isset($_POST['wpsc_ajax_action']) && $_POST['wpsc_ajax_action']!='empty_cart'))
    {
    	$wpsc_cart=find_cart();
    	$_SESSION['current_cart)']=$wpsc_cart;
    }
    if ($_SESSION['current_cart)'] && $_SESSION['current_cart)']!=$wpsc_cart)
    {
    	$_SESSION['current_cart)']=save_cart();
    }
    //if(isset($_POST['save_cart']))
    //	{ save_cart(); }
    ?>
    <?php // END FUNCTIONS FOR SAVING CART WITHOUT CHECKOUT ?>

    Put this code (to empty cart after checkout) in file plugins/wp-e-commerce/wpsc-includes/cart.class.php
    after line
    do_action('wpsc_save_cart_item', $cart_id, $this->product_id);

    // delete cart information from custom introduced db table
    global $user_ID;
    $wpdb->delete( 'custom_wp_wpsc_cart', array( 'user_ID' => $user_ID ), array( '%d' ) );
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Shopping cart not saving items after logout’ is closed to new replies.