Add WooCommerce Account Endpoints to SuperSide Me

WooCommerce uses “endpoints” to quickly create a menu for a customer’s account page. Because this is not a registered menu location, these endpoints are not visible to SuperSide Me, so they’re not added to the menu panel. If you would like to have the endpoints added to the menu panel, it’s easy enough to do so with a filter:

<?php
// Do not include the opening tag.
add_filter( 'supersideme_menu_output', 'prefix_add_woo_account_menu_supersideme' );
/**
* Mimic the WooCommerce account menu and add it to the SuperSide Me menu panel.
*
* @param $output_menu
*
* @return array
*/
function prefix_add_woo_account_menu_supersideme( $output_menu ) {
if ( ! function_exists( 'wc_get_account_menu_items' ) || ! is_user_logged_in() ) {
return $output_menu;
}
$wc_menu = '<h3>' . __( 'My Account', 'prefix-text-domain' ) . '</h3>';
foreach ( wc_get_account_menu_items() as $endpoint => $label ) {
$wc_menu .= sprintf( '<li class="%s"><a href="%s">%s</a></li>',
wc_get_account_menu_item_classes( $endpoint ),
esc_url( wc_get_account_endpoint_url( $endpoint ) ),
$label
);
}
$output_menu[] = $wc_menu;
return $output_menu;
}
view raw functions.php hosted with ❤ by GitHub

Please note that this function only checks if the appropriate WooCommerce function is available and if the user is logged in. If you want the links to be added only on the account page, you’ll need to further customize this code.

Return to SuperSide Me
Bars Code Check chevron-down chevron-left chevron-right chevron-up Envelope Laptop Search Times Facebook GitHub Google Plus Instagram LinkedIn Pinterest Twitter WordPress Logo Wordpress Simple