I am attempting to add a custom page to the customers 'account' section, which will allow the user to edit their order. At present I have been able to set an end point for the url and pick it up, but I need to get WooCommerce to initiate the page layout and be able to set the template location.
The URL being called:
/my-account/edit-order/55/
This is in the functions.php
file, with the end point set and template override:
// Working
add_action( 'init', 'add_endpoint' );
function add_endpoint(){
add_rewrite_endpoint( 'edit-order', EP_ALL );
}
// need something here to check for end point and run page as woocommerce
// Not been able to test
add_filter( 'wc_get_template', 'custom_endpoint', 10, 5 );
function custom_endpoint($located, $template_name, $args, $template_path, $default_path){
if( $template_name == 'myaccount/my-account.php' ){
global $wp_query;
if(isset($wp_query->query['edit-order'])){
$located = get_template_directory() . '/woocommerce/myaccount/edit-order.php';
}
}
return $located;
}
Thanks for any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…