I'm adding online tracking to my theme in Wordpress (version 5.0.3) and Woocommerce (version 3.5.4).
What I've done is create a new template under the myaccount
subdirectory in Woocommerce called order-tracking.php
so the path to the file from the Child theme directory is /woocommerce/myaccount/order-tracking.php
I've written the code below in order to pull the content from order-tracking.php
which for now is just a simple <?php echo 'Working'; ?>
to verify it's working:
/*
* Adding Track Your Order Tab to My Account menu
*/
/**
* Register new endpoints to use inside My Account page.
*/
add_action( 'init', 'my_account_new_endpoints' );
function my_account_new_endpoints() {
add_rewrite_endpoint( 'tracking', EP_ROOT | EP_PAGES );
}
/**
* Get new endpoint content
*/
add_action( 'woocommerce_account_tracking_endpoint', 'tracking_endpoint_content' );
function tracking_endpoint_content() {
get_template_part('order-tracking');
}
/**
* Edit my account menu order
*/
function my_account_menu_order() {
$menuOrder = array(
'orders' => __( 'Your Orders', 'woocommerce' ),
'tracking' => __( 'Track Your Order', 'woocommerce' ),
'downloads' => __( 'Downloads', 'woocommerce' ),
'edit-address' => __( 'Addresses', 'woocommerce' ),
'edit-account' => __( 'Account Details', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
'dashboard' => __( 'Dashboard', 'woocommerce' )
);
return $menuOrder;
}
add_filter ( 'woocommerce_account_menu_items', 'my_account_menu_order' );
When on the website, I click on the backend and get the below picture:
I've also tried copying one of the existing templates from the woocommerce/myaccount
plugin directory to see if there was something I needed to intiate via PHP but this had the same effect as above (no effect).
This leads me to believe I'm missing something on my /*** Get new endpoint content */
section.
Thoughts? Criticisms? All are appreciated. Please and thank you!