Join

Add a Custom WooCommere Endpoint

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new PHP code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

In this snippet example, we are adding a custom WooCommerce Endpoint named ‘Support’. 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');
}