Support » Plugin: WooCommerce » [Plugin: WooCommerce – excelling eCommerce] Logout code snippet

  • Hi,

    I’m trying to add a logout link when the user is logged into the site. I’m currently using this code on my functions.php page:

    <ul class="quick-cart">
    
    		<li><span class="quick-cart-copy">Your Cart Has:</span><?php global $woocommerce; ?>
    
    		<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
    
    		</li>
    
    		<li><?php if (sizeof($woocommerce->cart->cart_contents)>0) :?>
    
    		<a href="<?php echo $woocommerce->cart->get_checkout_url()?>" title="<?php _e('Checkout','woothemes') ?>" class="checkout button">  <?php _e('Checkout','woothemes') ?></a>
    
    		<?php endif; ?> </li>
    
    		<li>  <?php if ( is_user_logged_in() ) { ?>
    
    		<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account','woothemes'); ?>" class="my-account button">   <?php _e('My Account','woothemes'); ?></a>
    
    		<?php }
    
    		else { ?>
    
    		<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('Login / Register','woothemes'); ?>" class="login button"><?php _e('Login / Register','woothemes'); ?></a>
    
    		<?php } ?></li>
    
    	</ul>

    But there doesn’t appear to be anything that allows the user to logout. Any help is much appreciated. Thanks!

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ok, I figured it out. I just needed to add this snippet:

    <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>

    However, I’m getting a different issue where I can’t logout on IE8. Every other browser works fine, but on IE8, I have to click logout a couple of times and then it goes to a page that says “Are you sure you want to logout” and then redirects to a WordPress login page. Obviously, I don’t want customers going to that page. I’ve googled this issue and can’t seem to figure it out. Any help is greatly appreciated!

    I forgot to mention that this only happens when I’m logged in as a “customer.” It works fine if I’m logged in as an administrator. I’m using the latest version of WordPress and Woocommerce.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WooCommerce – excelling eCommerce] Logout code snippet’ is closed to new replies.