【发布时间】:2016-06-27 10:15:54
【问题描述】:
我正在尝试将自定义页面添加到客户的“帐户”部分,这将允许用户编辑他们的订单。目前我已经能够为 url 设置一个端点并提取它,但我需要让 WooCommerce 启动页面布局并能够设置模板位置。
被调用的 URL:
/my-account/edit-order/55/
这在 functions.php 文件中,设置了端点并覆盖了模板:
// 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;
}
感谢您的帮助。
【问题讨论】:
标签: php wordpress woocommerce endpoint account