我在WordPress和Woocommerce的一家电子商店工作。我买了一个模板,我正在寻找创建自己的自定义单页。
所以我跟着这个tutorial 但当我尝试使用此链接访问我的页面时//www.mywebsite.com/retour-produit/5904
我有一张白纸。
我在此处添加模板:/public_html/wp-content/themes/child-laneluxury/woocommerce/myaccount
//Ajouter le template du formulaire pour la demande de remboursement
add_filter( \'woocommerce_my_account_my_orders_actions\', \'wc_return_refund_form_template\', 10 , 2 );
function wc_return_refund_form_template($actions, $order){
global $woocommerce;
$user_id = $order->get_user_id();
$check_statut = get_user_meta($user_id, \'statut\', true);
if($order->has_status( \'completed\' ) && $check_statut == \'particulier\'){
//Si la date est dépassée par rapport aux options
$last_day = (get_option( \'wc_return_days\' ) == \'\') ? \'\' : date(\'Y-m-d\', strtotime($order->post->post_date . \' + \'. get_option( \'wc_return_days\' ) .\' days\'));
if ( ($last_day != \'\') && ($last_day < date("Y-m-d")) ){
}
else{
$actions[\'name\'] = array(
\'url\' => \'/retour-produit/\'.$order->get_order_number(),
\'name\' => \'Retour produit(s)\',
);
}
}
return $actions;
}
/*Custom route for customer refund form*/
function add_custom_refund_rewrite_rules(){
add_rewrite_rule(\'retour-produit/([^/]+)/?\', \'index.php?custompage_var=$matches[1]\', \'top\');
flush_rewrite_rules();
}
add_action( \'init\', \'add_custom_refund_rewrite_rules\' );
add_filter(\'query_vars\', \'handle_custompage_query_vars\');
function handle_custompage_query_vars($query_vars)
{
$query_vars[] = \'custompage_var\';
return $query_vars;
}
//Template
add_filter(\'template_include\', \'my_template\', 1, 1);
function my_template($template)
{
global $wp_query;
if (isset($wp_query->query_vars[\'custompage_var\'])) {
return child_template_directory.\'/woocommerce/myaccount/retour-produit.php\';
}
return $template;