Skip to content

Instantly share code, notes, and snippets.

@ryanbeymer
Forked from mclanecreative/my-account.php
Last active February 10, 2021 17:05
Show Gist options
  • Save ryanbeymer/d0c5e8711343f4d6761b to your computer and use it in GitHub Desktop.
Save ryanbeymer/d0c5e8711343f4d6761b to your computer and use it in GitHub Desktop.
Adds Tabs to WooCommerce "My Account" page. Instructions: add my-account.php to your [theme-folder]/woocommerce/myaccount/ folder.
<?php
/**
* A tabbed woocommerce My Account page
*
* @package WooCommerce/Templates
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wc_print_notices(); ?>
<div class="row">
<div class="col-xs-12">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#dashboard" aria-controls="dashboard" role="tab" data-toggle="tab">Dashboard</a></li>
<li role="presentation"><a href="#downloads" aria-controls="downloads" role="tab" data-toggle="tab">Downloads</a></li>
<li role="presentation"><a href="#orders" aria-controls="orders" role="tab" data-toggle="tab">Orders</a></li>
<li role="presentation"><a href="#address" aria-controls="address" role="tab" data-toggle="tab">Addresses</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="dashboard">
<?php
printf(
__( 'Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'woocommerce' ) . ' ',
$current_user->display_name,
wp_logout_url( get_permalink( wc_get_page_id( 'myaccount' ) ) )
);
printf( __( 'From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">edit your password and account details</a>.', 'woocommerce' ),
wc_customer_edit_account_url()
);
?>
</div>
<div role="tabpanel" class="tab-pane fade" id="downloads">
<?php wc_get_template( 'myaccount/my-downloads.php' ); ?>
</div>
<div role="tabpanel" class="tab-pane fade" id="orders">
<?php wc_get_template( 'myaccount/my-orders.php', array( 'order_count' => $order_count ) ); ?>
</div>
<div role="tabpanel" class="tab-pane fade" id="address">
<?php wc_get_template( 'myaccount/my-address.php' ); ?>
</div>
</div>
</div>
</div>
@jaxter555
Copy link

Thank You man,this has worked nicely on my site here http://xsupa.co.ke/my-account/ . Thank you so much

@alexjvr222
Copy link

Hi, would you please assist me over the CSS needed to show the tabs properly and the content? I tried to use the https://gist.github.com/mclanecreative/0531fae62910a5a9343f example but the contents on the tabs does not show. thanks

@flyize
Copy link

flyize commented Dec 9, 2015

Is there supposed to be CSS that goes with this?

@mtndev
Copy link

mtndev commented Oct 22, 2016

Thanks so much for this. Worked great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment