Skip to content

Instantly share code, notes, and snippets.

@haipham
Forked from ryanbeymer/my-account.php
Created February 10, 2021 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haipham/745d7bebd3412f275f5a1d5c6081c902 to your computer and use it in GitHub Desktop.
Save haipham/745d7bebd3412f275f5a1d5c6081c902 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment