WooCommerce 商店经理仅查看其特定国家/地区客户订单的订单 [英] WooCommerce Shop Managers view orders on their specific Country costumer orders only

查看:30
本文介绍了WooCommerce 商店经理仅查看其特定国家/地区客户订单的订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是基于国家/地区的限制 WooCommerce 插件,用户只能按自己的国家/地区订购.我在 3 个国家/地区有 3 个实体店分支机构,现在我为每个国家/地区创建了 3 个商店经理角色 1,我希望他们在订单页面上限制他们只能按指定的特定国家/地区查看客户订单.

I am using a Country Based Restriction WooCommerce plugin that users can order only by their own country. I have 3 physical store branches in 3 countries, and now I created 3 Shop Manager roles 1 per country, and i want them to restrict on the order page only they can view the customer orders by their specific assigned country.

我从这里找到了一个类似的问题,但仍然没有答案按国家/地区显示 w​​oocommerce 订单

I found a similar question from here but still no answer Show woocommerce orders by country

推荐答案

如果要按国家查询订单.这是一个示例代码.

If you want to query orders by country. Here is a sample code.

// If you want to get orders from America.
$args = array(
    'billing_country' => 'US',
);
$orders = wc_get_orders( $args );

请参阅此文档.

https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query#address-and-name

对于这个问题,

我在 3 个国家有 3 个实体店,现在我创建了 3 个每个国家/地区的商店经理角色 1,我希望他们限制订单页面只有他们可以通过他们的特定查看客户订单指定国家.

I have 3 physical store branches in 3 countries, and now I created 3 Shop Manager roles 1 per country, and i want them to restrict on the order page only they can view the customer orders by their specific assigned country.

我建议创建一个自定义shortcode,它将查询订单记录(使用上面提供的代码)使用分配给当前登录的当前国家/地区Shop经理(我建议为 Shop Manager 用户添加一个用户元数据,您可以在其中指定国家/地区代码 - 例如 PH 、 US )并列出

I suggest creating a custom shortcode that would query the Orders record(use the code provided above) using the current country assigned to the current logged in Shop Manager (I suggest adding a user meta for the Shop Manager user where you can assign country code - e.g PH , US ) and list

这是一个代码片段.

$currentUserId = get_current_user_id();
$currentShopManagerCountryCode = get_user_meta($currentUserId ,"assigned_country_code",true);
$args = array(
    'billing_country' => $currentShopManagerCountryCode,
);
$orders = wc_get_orders( $args );

这篇关于WooCommerce 商店经理仅查看其特定国家/地区客户订单的订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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