Add a Custom WooCommere Endpoint

Recommendation

Learn why I switched to WPCodeBox for managing code snippets for myself and for my clients.

Instructions

Snippet Type: PHP

  1. Copy the snippet.
  2. Add the snippet using WPCodeBox.
  3. Follow any customization notes provided.
  4. Save the snippet.
  5. Enable the snippet.
  6. Test.

Snippet

In this snippet example, we are adding a custom WooCommerce Endpoint named ‘Support’.

Customization Notes

Anywhere you see the word ‘Support’, change it to the name of your own page.

				
					// WOO NAVIVATION
function wpb_woo_my_account_order() {
	$myorder = array(
		'dashboard'          => __( 'Dashboard', 'woocommerce' ),
		'edit-account'       => __( 'Edit Account', 'woocommerce' ),
		'orders'             => __( 'Orders', 'woocommerce' ),
		'downloads'          => __( 'Downloads', 'woocommerce' ),
		'edit-address'       => __( 'Addresses', 'woocommerce' ),
		'payment-methods'    => __( 'Payment Methods', 'woocommerce' ),
		'support'            => __( 'Support', 'woocommerce' ),
		'customer-logout'    => __( 'Logout', 'woocommerce' ),
	);

	return $myorder;
}
add_filter ( 'woocommerce_account_menu_items', 'wpb_woo_my_account_order' );


// WOO REGISTER ENDPOINT
add_action( 'init', 'my_account_new_endpoints' );
     function my_account_new_endpoints() {
     add_rewrite_endpoint( 'support', EP_ROOT | EP_PAGES );
}

// WOO ENDPOINT LINK
 add_action( 'woocommerce_account_support_endpoint',
    'support_endpoint_content' );
    function support_endpoint_content() {
 get_template_part('my-account-support');
}