How to Add Custom Endpoints in WooCommerce?

By default Woocommerce has a bunch of endpoints on my account page (dashboard, orders, account etc.) but it has no built-in feature that allows us to add custom endpoints to our site. Hence, in this post I will show you how to add custom endpoints in Woocommerce.

Video: How to add custom endpoints in Woocommerce?

If adding custom code to your site is somewhat complicated to you, then take a look at this video here below. In it I demonstrate how to create a custom endpoint in Woocommerce.

How to add custom endpoints in Woocommerce?

First, go to your site and add this code here below using Code Snippets plugin (or your child theme’s functions.php file) paste the code and activate it. If you’re a pro then take a look at the WpCodeBox plugin which is is a much better alternative to Code Snippets. You can grab WPCodeBox with 20% discount here (use WPSH20 coupon code).

Now, some explanations for the code below:

  • Take a look at the comments inside the code
  • You need to change your endpoint slug and title accordingly (see lines 8, 18 and 46)
  • Line 23 contains woocommerce_account_support_endpoint and you need to change it accordingly. That is, if your endpoint slug is your-courses then this line should look woocommerce_account_your-courses_endpoint
  • After saving and activating your snippet you need to go to Settings > Permalinks and just push “Save Changes” button. Otherwise you end up with “Oops, that page cannot be found” error
// Add new tab to My Account menu

add_filter ( 'woocommerce_account_menu_items', 'wpsh_custom_endpoint', 40 );
function wpsh_custom_endpoint( $menu_links ){
 
	$menu_links = array_slice( $menu_links, 0, 5, true ) 
		// Add your own slug (support, for example) and tab title here below
	+ array( 'support' => 'Support' ) 
	+ array_slice( $menu_links, 5, NULL, true );
 
	return $menu_links;
 
}
// Let’s register this new endpoint permalink

add_action( 'init', 'wpsh_new_endpoint' );
function wpsh_new_endpoint() {
	add_rewrite_endpoint( 'support', EP_PAGES ); // Don’t forget to change the slug here
}

// Now let’s add some content inside your endpoint

add_action( 'woocommerce_account_support_endpoint', 'wpsh_endpoint_content' );
function wpsh_endpoint_content() {
 
	// At the moment I will add Learndash profile with the shordcode
	echo (
		'<h3>Send us an email</h3>
	<p>Lorem ipsum dolor sit amet consectetur adipiscing elit facilisis tincidunt, nisi sociosqu lacinia auctor inceptos libero conubia accumsan</p>'
		 );
	echo do_shortcode('[fluentform id="1"]');
}

// NB! In order to make it work you need to go to Settings > Permalinks and just push "Save Changes" button.

// If you need to change endpoint order then add your own order here

add_filter ( 'woocommerce_account_menu_items', 'wpsh_custom_endpoint_order' );
function wpsh_custom_endpoint_order() {
 $myorder = array(
        'dashboard'          => __( 'Dashboard', 'woocommerce' ),
        'orders'             => __( 'Your orders', 'woocommerce' ), 
        'edit-account'       => __( 'Account details', 'woocommerce' ),
	 	'edit-address'       => __( 'Edit address', 'woocommerce' ),
	 	'woo-wish-list'       => __( 'Wishlist', 'woocommerce' ),
	 	'support'    => __( 'Support', 'woocommerce' ), // Don’t forget to change the slug and title here
        'customer-logout'    => __( 'Log out', 'woocommerce' ),
    );
    return $myorder;
}

How to display Learndash’s profile page in Woocommerce my account tab?

If you would like to display Learndash’s profile page in Woocommerce my account tab, then use the same snippet here above and add [ld_profile] shortcode instead of a contact form.

Also, I have made a thorough tutorial on how to merge Learndash and Woocommerce account pages.

Useful Woocommerce tutorials

Here are some of my favorite Wordpress tools

Thank you for reading this article. I hope you found it helpful as you build your own websites and e-commerce sites. Here are some tools I use as a Wordpress developer and enthusiast that I hope you’ll also find helpful.

These are affiliate links, so if you do decide to use any of them, I’ll earn a commission and this helps me create these tutorials and make Youtube videos. But in all honesty, these are the exact tools that I use and recommend to everyone, even my friends and family.

Themes: For the last couple of years I have two go-to themes which I use for every kind of projects. Those two themes are Blocksy theme and Kadence Theme. On this site and my Youtube channel you’ll see a lot of tutorials I have made about them. If you would like to get a 10% discount for both of them then:

Code Snippets manager: WPCodeBox allows you to add code snippets to your site. Also, it allows you to build and manage your WordPress Code Snippets library in the cloud. You can grab it with the 20% discount here (SAVE 20% Coupon: WPSH20).

Contact forms: There are hundreds of contact forms out there but Fluent Forms is the one I like the most. If you need a 20% discount then use this link (save 20% coupon is WPSH20).

Gutenberg add-ons: If I need a good Gutenberg blocks add-on then Kadence Blocks is the one I have used the most. You’ll get 10% discount with the coupon SIMPLEHACKS here.

Website migration: While building a website you probably need a good plugin that can help you with the migration, backups, restoration and staging sites. Well, WpVivid is the one I have used for the last couple of years. If you use this link along with the WPSH20 coupon you’ll get 20% discount.

Woocommerce extensions: There are a bunch of Woocommerce extensions that I really like but the one that stands really out is Advanced Dynamic Pricing. Once again, you’ll get a 20% discount if you use this link here (save 20% coupon is WPSH20)

Web Hosting: If you would like to have a really fast and easy to use managed cloud hosting, then I recommend Verpex Hosting (see my review here). Btw, this site is hosted in Verpex.)

To see all my of most up-to-date recommendations, check out this resource that I made for you!

Do you want to thank me and buy me a beer?

Every donation is entirely welcome but NEVER required. Enjoy my work for free but if you would like to thank me and buy me a beer or two then you can use this form here below.

Choose amount

Best selling plugins

Janek T.
Janek T.

I am a Wordpress enthusiast who has been making websites since 2011. In this site I am offering simple to follow tips on how to use Wordpress and Woocommerce.
If you want to be the first to be notified about the new tutorials then please subscribe to my Youtube channel here
Follow me in Twitter here

Articles: 89