I would like to add a link in the My Account -> Orders -> Order Details page, that would point to a custom view-photo.php file, which will display a few images of the product from that order. I've placed that file in custom-theme/woocommerce/myaccount.
I've added this to theme's function.php file:
add_action( 'init', 'add_endpoint' );
function add_endpoint(){
add_rewrite_endpoint( 'photos', EP_ROOT | EP_PAGES );
}
add_filter( 'wc_get_template', 'custom_endpoint', 10, 5 );
function custom_endpoint($located, $template_name, $args, $template_path, $default_path){
if( $template_name == 'myaccount/view-photos.php' ){
global $wp_query;
if(isset($wp_query->query['view-photos'])){
$located = get_stylesheet_directory() . '/woocommerce/myaccount/view-photos.php';
}
}
return $located;
}
I've tried linking to view-photos.php from Order Details page in multiple ways, by setting href to 'view-photos', 'view-photos.php', '../view-photos', and such, but I cannot get to view-photos.php in any way.
Currently, in My Account -> Orders page, link to Order details page goes something like this: .../my-account/view-order/#order-no. I would like for this link to view-photos.php to be similar: .../my-account/view-photos/#order-no.
How do I link to that page? And how to link back to Orders Details page from that page?