On this video I’m going to indicate you find out how to add Woocommerce my account tabs. Additionally, I’m going to indicate you find out how to take away, rename and reorder them with the couple of clicks. So, should you’re prepared then soar in.
NB! With the intention to use all these snippets proven on this submit you want add them inside your youngster theme’s features.php file or higher but, use Code Snippets plugin. This manner you’re not going to lose these modifications in case you’re switching your theme.
Video: How one can add, rename, take away and reorder Woocommerce My Account tabs?
Please check out the video right here under as a result of this fashion it will likely be a lot simpler so that you can perceive find out how to accomplish all that and add Woocommerce my account tabs..
How one can add Woocommerce My Account tabs?
It’s time to take a better look on find out how to add Woocommerce My Account tabs. I’m going to indicate you to instance. With the primary of them we’ll add a assist tab and with the opposite one we are going to merge Learndash profile into Woocommerce my account. (see the screenshot under).
So, go to Snippets >> Add new and provides the snippet a title. Fo instance “Assist tab”. Subsequent, paste this code snippet contained in the code field. Concentrate that there’s a shortcode and content material inside Step 4, so don’t overlook to alter it accordingly.
// Add Woocommerce My Account tab for Assist
// 1. Register new customer-support endpoint (URL) for My Account web page
add_action( 'init', 'add_support_endpoint' );
operate add_support_endpoint() EP_PAGES );
// 2. Add new question var
add_filter( 'query_vars', 'support_query_vars', 0 );
operate support_query_vars( $vars ) {
$vars[] = 'customer-support';
return $vars;
}
// 3. Insert the brand new endpoint into the My Account menu
add_filter( 'woocommerce_account_menu_items', 'add_new_support_tab' );
operate add_new_support_tab( $objects ) {
$objects['customer-support'] = 'Assist';
return $objects;
}
// 4. Add content material to the added tab
add_action( 'woocommerce_account_customer-support_endpoint', 'support_tab_content' ); // Notice: add_action should comply with 'woocommerce_account_{your-endpoint-slug}_endpoint' format
operate support_tab_content() {
echo '<h4><robust>Assist</robust></h4>
<p>Fermentum tristique non imperdiet vulputate ridiculus platea arcu suspendisse donec</p>';
echo do_shortcode( '[fluentform id="1"]' ); // Right here goes your shortcode if wanted
}
// 5. Go to Settings >> Permalinks and re-save permalinks. In any other case you'll find yourself with 404 Web page not discovered error
Additionally, don’t overlook to go to Settings >> Permalinks and resave your permalinks
How one can merge Leardash profile and Woocommerce My account web page?
I’ve made an in-depth tutorial on find out how to merge Learndash and Woocommerce however immediately I’m simply going to indicate find out how to present Learndash profile inside Woocommerce my account. You simply want so as to add this snippet right here under.
// 1. Register new purchased-courses endpoint (URL) for My Account web page
add_action( 'init', 'add_lms_endpoint' );
operate add_lms_endpoint() EP_PAGES );
// 2. Add new question var
add_filter( 'query_vars', 'courses_query_vars', 0 );
operate courses_query_vars( $vars ) {
$vars[] = 'purchased-courses';
return $vars;
}
// 3. Insert the brand new endpoint into the My Account menu
add_filter( 'woocommerce_account_menu_items', 'add_new_courses_tab', 40 );
operate add_new_courses_tab( $objects ) {
$objects['purchased-courses'] = 'Your programs';
return $objects;
}
// 4. Add content material to the added tab
add_action( 'woocommerce_account_purchased-courses_endpoint', 'course_tab_content' ); // Notice: add_action should comply with 'woocommerce_account_{your-endpoint-slug}_endpoint' format
operate course_tab_content() {
echo '<h4><robust>All of your programs</robust></h4>
<p>Fermentum tristique non imperdiet vulputate ridiculus platea arcu suspendisse donec</p>';
echo do_shortcode( ' [ld_profile]' ); // Right here goes your shortcode if wanted
}
As earlier than, don’t overlook to go to Settings >> Permalinks and resave your permalinks
How one can take away Woocommerce my account tabs?
There are a bunch of Woocommerce endpoints, and perhaps you don’t want a few them and due to this fact let’s see find out how to take away Woocommerce my account tabs. For instance, let’s take away Downloads tab (endpoint). It’ s pretty straightforward. Go to Woocommerce >> Settings >> Advandes and try the “Account endpoints” part.
Now discover Downloads and delete content material from it and save modifications (see the screenshot).
It will take away Downaods endpoint out of your Woocommerce My account web page.
How one can take away Woocommerce Dashboard tab from My account web page?
Though you possibly can take away all different tabs, you can’t use this technique proven above to take away Woocommerce Dashboard tab from my account web page. To perform that, use this snippet right here as an alternative.
operate remove_dashboard_tab($objects) {
unset($objects['dashboard']);
return $objects;
}
add_filter ('woocommerce_account_menu_items', 'remove_dashboard_tab');
How one can reorder Woocommerce my account tabs?
Now let’s check out find out how to take away Woocommerce my account tabs. Since we added two tabs (Assist and Your programs) earliel they are going to find yourself down backside on the tabs record. I wish to reorder their location. So, let’s add this code to the code snippets.
// Reorder Woocommerce my account tabs?
operate change_my_account_menu_order() {
$menuOrder = array(
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
'purchased-courses' => __( 'Your programs', 'woocommerce' ),
'customer-support' => __( 'Assist', 'woocommerce' ),
'downloads' => __( 'Downloads', 'woocommerce' ),
'edit-address' => __( 'My ddresses', 'woocommerce' ),
'edit-account' => __( 'Account Particulars', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' )
);
return $menuOrder;
}
add_filter ( 'woocommerce_account_menu_items', 'change_my_account_menu_order' );
Concentrate that you could add all of the energetic tabs inside this code. You probably have eliminated Downloads as I confirmed beforehand then don’t add Downloads within the record. Now simply reorder them as you want. As you see Your Programs is within the third place and Assist is fourth.
ALSO don’t overlook to pay attentio to the endpoint URL-s half ins the code ( ‘purchased-courses’ for instance).
How one can rename Woocommerce my account tabs?
If you could rename Woocommerce my account tabs then take the code proven within the earlier step and simply rename your tab names. For instance, I’m going to rename Dashboard to My dashboard and Orders to My orders.
operate rename_my_account_menu_order() {
$menuOrder = array(
'dashboard' => __( 'My dashboard', 'woocommerce' ),
'orders' => __( 'My orders', 'woocommerce' ),
'purchased-courses' => __( 'Your programs', 'woocommerce' ),
'customer-support' => __( 'Assist', 'woocommerce' ),
'downloads' => __( 'Downloads', 'woocommerce' ),
'edit-address' => __( 'My ddresses', 'woocommerce' ),
'edit-account' => __( 'Account Particulars', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' )
);
return $menuOrder;
}
add_filter ( 'woocommerce_account_menu_items', 'rename_my_account_menu_order' );
If you could reorder and rename them collectively then use one snippet for each.
Properly, that’s mainly it. Now you understand how to rename, take away, reorder and add Woocommerce My Account tabs?