如何在Woocommerce中将订单分配给某个商店经理 [英] How can I assign an order to a certain shop manager in Woocommerce

查看:118
本文介绍了如何在Woocommerce中将订单分配给某个商店经理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一家服务woocommerce网上商店,其中有三名商店经理.

we have a services woocommerce online shop with three shop managers.

我们想过滤新订单并将其分配给这三个经理之一.管理者只能看到他们分配的订单,而不能访问或看到其余的订单.

We would like to filter new orders and assign them to one of these three managers. The managers only can see their assigned orders, and can't access or see the rest.

也许可以通过custom_field过滤后端视图(管理面板)来完成此操作,但是我不知道这是否是一种好方法.也许有一个基于角色能力的插件.

Maybe this could be done by filtering the backend view (admin panel) via custom_field, but I don't know if it is a good approach. Maybe there is a plugin based on role capabilites.

有什么建议吗?

谢谢.

推荐答案

此功能使订单仅向其自己的作者(商店经理)显示:

This function makes the orders display only to its own authors (shop managers):

function alter_the_edit_screen_query( $wp_query ) {
    if ( ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) and ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php?post_type=unit' ) === false ) and ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php?post_type=course' ) === false ) ) {
        if ( !current_user_can( 'activate_plugins' ) )  {
add_action( 'views_edit-post', 'remove_items_from_edit' );
            global $current_user;
            $wp_query->set( 'author', $current_user->id );
        }
    }
}

add_filter('parse_query', 'alter_the_edit_screen_query' );

function remove_items_from_edit( $views ) {
    unset($views['all']);
    unset($views['publish']);
    unset($views['trash']);
    unset($views['draft']);
    unset($views['pending']);
    return $views;
}

此其他功能对非管理员用户(作为商店经理)隐藏所有订单"标签:

This other function hides "All orders" tab to no-admin users (as shop manager):

function my_custom_admin_head() {
   if ( ! current_user_can( 'update_core' ) ) {
    echo '<style type="text/css">
    ul.subsubsub li.all { display:none!important; }
    </style>';
}
}
add_action( 'admin_head', 'my_custom_admin_head' );

这篇关于如何在Woocommerce中将订单分配给某个商店经理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆