Skip to content

Instantly share code, notes, and snippets.

@geeac
Created October 25, 2017 09:33
Show Gist options
  • Save geeac/63f36ae7f20709fac22692fded72caf1 to your computer and use it in GitHub Desktop.
Save geeac/63f36ae7f20709fac22692fded72caf1 to your computer and use it in GitHub Desktop.
custom endpoint My Account
// create a custom end point in the My Accunt Page
function custom_wc_end_point() {
if(class_exists('WooCommerce')){
add_rewrite_endpoint( 'wholesale-ordering', EP_ROOT | EP_PAGES );
}
}
add_action( 'init', 'custom_wc_end_point' );
function custom_endpoint_query_vars( $vars ) {
$vars[] = 'wholesale-ordering';
return $vars;
}
add_filter( 'query_vars', 'custom_endpoint_query_vars', 0 );
function ac_custom_flush_rewrite_rules() {
flush_rewrite_rules();
}
function my_custom_my_account_menu_items( $items ) {
// Remove the logout menu item.
$logout = $items['customer-logout'];
unset( $items['customer-logout'] );
// Insert your custom endpoint.
$items['wholesale-ordering'] = __( 'Wholesale Ordering', 'woocommerce' );
// Insert back the logout item.
$items['customer-logout'] = $logout;
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment