-
-
Save dexit/6f0b59759b73031aefe089575a3645cb to your computer and use it in GitHub Desktop.
custom endpoint My Account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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