Tips on how to Add Customized Endpoints in WooCommerce?

By default Woocommerce has a bunch of endpoints on my account web page (dashboard, orders, account and so on.) however it has no built-in function that enables us so as to add customized endpoints to our website. Therefore, on this put up I’ll present you add customized endpoints in Woocommerce.

Video: Tips on how to add customized endpoints in Woocommerce?

If including customized code to your website is considerably difficult to you, then check out this video right here under. In it I display create a customized endpoint in Woocommerce.

Tips on how to add customized endpoints in Woocommerce?

First, go to your website and add this code right here under utilizing Code Snippets plugin (or your baby theme’s capabilities.php file) paste the code and activate it. For those who’re a professional then check out the WpCodeBox plugin which is is a significantly better different to Code Snippets.

WpCodeBox is my favourite code snippets supervisor for WordPress. This can be a premium plugin and if you happen to’re , then seize WPCodeBox with a pleasant 20% low cost right here (SAVE 20% Coupon WPSH20).

Now, some explanations for the code under:

  • Check out the feedback contained in the code
  • You must change your endpoint slug and title accordingly (see traces 8, 18 and 46)
  • Line 23 comprises woocommerce_account_support_endpoint and it’s essential to change it accordingly. That’s, in case your endpoint slug is your-courses then this line ought to look woocommerce_account_your-courses_endpoint
  • After saving and activating your snippet it’s essential to go to Settings > Permalinks and simply push “Save Adjustments” button. In any other case you find yourself with “Oops, that web page can’t be discovered” error

// Add new tab to My Account menu

add_filter ( 'woocommerce_account_menu_items', 'wpsh_custom_endpoint', 40 );
operate wpsh_custom_endpoint( $menu_links ){
 
	$menu_links = array_slice( $menu_links, 0, 5, true ) 
		// Add your individual slug (help, for instance) and tab title right here under
	+ array( 'help' => 'Help' ) 
	+ array_slice( $menu_links, 5, NULL, true );
 
	return $menu_links;
 
}
// Let’s register this new endpoint permalink

add_action( 'init', 'wpsh_new_endpoint' );
operate wpsh_new_endpoint() {
	add_rewrite_endpoint( 'help', EP_PAGES ); // Don’t overlook to alter the slug right here
}

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

add_action( 'woocommerce_account_support_endpoint', 'wpsh_endpoint_content' );
operate wpsh_endpoint_content() {
 
	// In the intervening time I'll add Learndash profile with the shordcode
	echo (
		'<h3>Ship us an e mail</h3>
	<p>Lorem ipsum dolor sit amet consectetur adipiscing elit facilisis tincidunt, nisi sociosqu lacinia auctor inceptos libero conubia accumsan</p>'
		 );
	echo do_shortcode('');
}

// NB! In an effort to make it work it's essential to go to Settings > Permalinks and simply push "Save Adjustments" button.

// If it's essential to change endpoint order then add your individual order right here

add_filter ( 'woocommerce_account_menu_items', 'wpsh_custom_endpoint_order' );
operate wpsh_custom_endpoint_order() {
 $myorder = array(
        'dashboard'          => __( 'Dashboard', 'woocommerce' ),
        'orders'             => __( 'Your orders', 'woocommerce' ), 
        'edit-account'       => __( 'Account particulars', 'woocommerce' ),
	 	'edit-address'       => __( 'Edit handle', 'woocommerce' ),
	 	'woo-wish-list'       => __( 'Wishlist', 'woocommerce' ),
	 	'help'    => __( 'Help', 'woocommerce' ), // Don’t overlook to alter the slug and title right here
        'customer-logout'    => __( 'Log off', 'woocommerce' ),
    );
    return $myorder;
}

Tips on how to show Learndash’s profile web page in Woocommerce my account tab?

If you want to show Learndash’s profile web page in Woocommerce my account tab, then use the identical snippet right here above and add [ld_profile] shortcode as a substitute of a contact type.

Additionally, I’ve made an intensive tutorial on merge Learndash and Woocommerce account pages.

Helpful Woocommerce tutorials

  • Tips on how to Cover Woocommerce Delivery Strategies (Conditionally) – A Full Information

  • Tips on how to Create Customized Product Badges for Woocommerce?

  • Tips on how to filter WooCommerce admin merchandise by on sale?

  • Tips on how to show Woocommerce retailer handle for Native pickup delivery technique?

  • Tips on how to Cover Woocommerce delivery strategies for particular delivery lessons?

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top