使用 WooCommerce 的自定义订单列表页面

Custom Order Listing Page With WooCommerce

我创建了一个插件,它有一个单独的订单列表页面。因为它看起来与 WooCommerce 的订单列表页面一样,但是。我无法获得订单的评论,所以我将我的自定义 post 类型添加到 wc_order_types 之后没有列出任何订单.. 它显示为空 table。 ?

add_filter( 'wc_order_types',array($this,'add_wc_order_types'),10,3);
public function add_wc_order_types($order_types,$type){
    $order_types[] = WC_QD_PT;
    return $order_types;
}

apply_filters( 'wc_order_types', $order_types, $for ); 是默认值 wc_filters 它需要 2 个参数,您在此处要求 3 个 add_filter( 'wc_order_types',array($this,'add_wc_order_types'),10,3); 并再次提供 2.

访问http://docs.woothemes.com/wc-apidocs/source-function-wc_get_order_types.html#149它可能会帮助你做到这一点。

我通过在我的钩子函数中添加一个 if 条件解决了这个问题 function add_wc_order_types($order_types,$type){ $order_type = $order_types; if('' == $type){ $order_type[] = WC_QD_PT; } return $order_type; }