Shopping Cart (0)

Customer Logged In or Logged out of a Jigoshop store, php snippet

The purpose of this SlickTips php snippet is to show you how to check if a customer is logged in or not and show appropriate buttons based on their status for a Jigoshop store.

The Idea

– If user is not logged in show the “Log In” button so the user can log into the store.

OTHERWISE

– If user is logged in show “Log Out” and “My Account” buttons in the store menu.

The Script

You can add or overwrite this by going to your themes header.php file and placing this in the store menu area.

wp-content/themes/YOURTHEME/header.php

Overwrite your existing store menu if you are using a Jigoshop store theme OR just place in the header where you would like the store menu to be.

//Only show "Login" button if not logged in otherwise show "My Account" button if user logged in.
<?php if ( is_user_logged_in() ) {
echo '<a href="/my-account/" class="header-my-account-btn">My Account</a>';
} else {
echo '<a class="header-store-sign-in" href="/wp-login.php"> Login</a>';
}

//Always show "Checkout" and "Cart" buttons
echo '/ <a class="header-store-sign-up" href="/checkout/">Checkout</a> / <a class="header-store-checkout" href="/cart/">Cart</a>';

//Only show "Log Out" button If user is logged in show.
if ( is_user_logged_in() ) {
echo '/ <a href="/wp-login.php?loggedout=true" class="header-logout-btn">Log out</a>';
}
?>

Add Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

All Plugins on Unlimited Sites for $249 All Access Pass