Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress WooCommerce-订阅在编辑订阅中添加自定义字段_Wordpress_Woocommerce_Hook Woocommerce_Woocommerce Subscriptions - Fatal编程技术网

Wordpress WooCommerce-订阅在编辑订阅中添加自定义字段

Wordpress WooCommerce-订阅在编辑订阅中添加自定义字段,wordpress,woocommerce,hook-woocommerce,woocommerce-subscriptions,Wordpress,Woocommerce,Hook Woocommerce,Woocommerce Subscriptions,我正在使用和插件,它按照我的期望工作 但是,我需要在编辑订阅页面中添加一个自定义字段,因此我按照下面的钩子和代码在编辑订阅页面中添加我的新字段 add_action('woocommerce_admin_order_data_after_order_details', 'showWCSubscriptionCustomFields'); function showWCSubscriptionCustomFields($subscription) { $currentPage =

我正在使用和插件,它按照我的期望工作

但是,我需要在编辑订阅页面中添加一个自定义字段,因此我按照下面的钩子和代码在编辑订阅页面中添加我的新字段

add_action('woocommerce_admin_order_data_after_order_details', 'showWCSubscriptionCustomFields');




function showWCSubscriptionCustomFields($subscription) {

    $currentPage = get_current_screen();

    // If page is "Edit Subscription" page, then only show 
    if ($currentPage->action == 'add')
        return;

    // Getting all the users 
    $mindeskUsers = getAllUsers();

?>
    <br class="clear" />
    <p class="form-field form-field-wide">
        <label for="mindesk_wc_subscriptions_var_client_user_id">Mindesk VAR Client User:</label>
        <?php

        $selectedUser = get_post_meta($subscription->get_id(), 'mindesk_wc_subscriptions_var_client_user_id', true);

        echo getUsersListSelect('mindesk_wc_subscriptions_var_client_user_id', $selectedUser, $mindeskUsers, 'mindesk_select2');
        ?>
    </p>
<?php

}
现在我的查询是,当我进入编辑顺序页面时,我也可以看到这个新字段。我不想在此页面中显示此新自定义字段

我试着找到各种各样的钩子,试了一些,但没有一个适合我

有人可以指导我如何仅在编辑订阅页面中显示新的自定义字段吗。。如何隐藏编辑顺序页面的新字段

任何帮助或指导都将不胜感激


谢谢

将这两个类
hide if admin
mindesk var
添加到您的
p
标签中。检查下面的代码

add_action('woocommerce_admin_order_data_after_order_details', 'showWCSubscriptionCustomFields');
function showWCSubscriptionCustomFields($subscription) {

    $currentPage = get_current_screen();

    // If page is "Edit Subscription" page, then only show 
    if ($currentPage->action == 'add')
        return;

    // Getting all the users 
    $mindeskUsers = getAllUsers();

?>
    <br class="clear" />
    <p class="form-field form-field-wide mindesk-var hide-if-admin">
        <label for="mindesk_wc_subscriptions_var_client_user_id">Mindesk VAR Client User:</label>
        <?php

        $selectedUser = get_post_meta($subscription->get_id(), 'mindesk_wc_subscriptions_var_client_user_id', true);

        echo getUsersListSelect('mindesk_wc_subscriptions_var_client_user_id', $selectedUser, $mindeskUsers, 'mindesk_select2');
        ?>
    </p>
<?php

}

function hide_mindesk_var_client_user(){
    ?>
    <style type="text/css">
        .post-type-shop_order .mindesk-var.hide-if-admin{display: none;}
    </style>
    <?php
}

add_action( 'admin_footer', 'hide_mindesk_var_client_user', 10, 1 );
add_action('woocommerce_admin_order_data_,在_order_details之后,'showWCSubscriptionCustomFields');
函数showWCSubscriptionCustomFields($subscription){
$currentPage=获取当前屏幕();
//如果页面为“编辑订阅”页面,则仅显示
如果($currentPage->action=='add')
返回;
//获取所有用户
$mindeskUsers=getAllUsers();
?>

Mindesk VAR客户端用户:

.post-type-shop_order.mindesk-var.hide-if-admin{display:none;}
你可以用CSS隐藏。谢谢回复@Bhautik。我应该怎么做才能签入CSS?这个
Mindesk VAR客户端用户:
你想隐藏的字段?是的,没错……好吧……让我试试……不……它不起作用……它仍然显示在编辑订单页面上。你能分享编辑订单页面的屏幕截图和代码吗?当然,让我分享它的内容正在同时从..编辑订阅页和编辑订单页。。
add_action('woocommerce_admin_order_data_after_order_details', 'showWCSubscriptionCustomFields');
function showWCSubscriptionCustomFields($subscription) {

    $currentPage = get_current_screen();

    // If page is "Edit Subscription" page, then only show 
    if ($currentPage->action == 'add')
        return;

    // Getting all the users 
    $mindeskUsers = getAllUsers();

?>
    <br class="clear" />
    <p class="form-field form-field-wide mindesk-var hide-if-admin">
        <label for="mindesk_wc_subscriptions_var_client_user_id">Mindesk VAR Client User:</label>
        <?php

        $selectedUser = get_post_meta($subscription->get_id(), 'mindesk_wc_subscriptions_var_client_user_id', true);

        echo getUsersListSelect('mindesk_wc_subscriptions_var_client_user_id', $selectedUser, $mindeskUsers, 'mindesk_select2');
        ?>
    </p>
<?php

}

function hide_mindesk_var_client_user(){
    ?>
    <style type="text/css">
        .post-type-shop_order .mindesk-var.hide-if-admin{display: none;}
    </style>
    <?php
}

add_action( 'admin_footer', 'hide_mindesk_var_client_user', 10, 1 );