【发布时间】:2018-03-04 16:25:28
【问题描述】:
我正在尝试创建一个工作流程,商店经理可以创建订单并将其标记为“待付款”、“处理中”,但只有管理员可以将订单标记为“完成”、“失败”等。
我找到的最接近的是this post:
<?php
if ( current_user_can(! 'administrator' ) ) {
$args = array( 'post_type' => 'post', 'post_status' => 'publish, pending,
draft' );
} else {
$args = array( 'post_type' => 'post', 'post_status' => 'publish' );
}
$wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?>
CONTENT
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
这应该适用于常规的 WP 帖子(虽然我还没有测试过),但我不确定如何申请 Woocommerce。我的最佳猜测是:
<?php
if ( current_user_can(! 'administrator' ) ) {
$args = array( 'post_type' => 'shop_order', 'order_status' => 'complete,failed' );
} else {
$args = array( 'post_type' => 'shop_order', 'post_status' => 'pending-payment,processing' );
}
$wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?>
CONTENT
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
但是我遇到了各种各样的错误!我也不确定它是否仅适用于编辑订单屏幕,而不适用于管理车间订单表批量操作下拉菜单。
任何帮助将不胜感激!
【问题讨论】:
-
除了管理员角色之外,您是否授予对 wp 管理仪表板的访问权限?或者您正在创建任何前端页面来列出所有订单和状态更新?
-
我应该把这些代码放在哪里?
标签: php wordpress woocommerce status orders