Skip to content

Instantly share code, notes, and snippets.

@kopepasah
Created November 9, 2012 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kopepasah/4047184 to your computer and use it in GitHub Desktop.
Save kopepasah/4047184 to your computer and use it in GitHub Desktop.
Creating an actual Shopp account menu for the account pages.
function shopp_account_menu() {
$shopp_pages = Storefront::pages_settings();
$site_url = str_replace( 'http://', '', get_bloginfo( 'url' ) );
$current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$needed_class = str_replace( $site_url . '/' . $shopp_pages['catalog']['slug'] . '/' . $shopp_pages['account']['slug'], '', $current_url );
if ( $needed_class == '/' ) {
$needed_class = str_replace( '/', 'profile', $needed_class );
} else {
$needed_class = str_replace( '/?', '', $needed_class );
}
if ( $needed_class == 'orders' ) {
$needed_class = 'your-orders';
} elseif ( $needed_class == 'profile' | $needed_class == 'menu' | $needed_class == 'acct' | empty( $needed_class ) ) {
$needed_class = 'my-account';
} else {
$needed_class = $needed_class;
}
?>
<ul class="shopp account-nav clearfix">
<?php while ( shopp( 'storefront', 'account-menu' ) ) : ?>
<?php
if ( $needed_class == str_replace( ' ', '-', strtolower( shopp( 'storefront', 'account-menu-item', array( 'return' => true ) ) ) ) ) {
$current_page = 'class="current"';
}
else {
$current_page = '';
}
?>
<li <?php echo $current_page; ?>>
<a class="btn" href="<?php shopp( 'storefront', 'account-menuitem', 'url' ); ?>"><?php shopp( 'storefront', 'account-menuitem' ); ?></a>
</li>
<?php endwhile; ?>
</ul>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment