【问题标题】:Woocommerce add new filter and new field to orders table in Analytics ordersWoocommerce 向 Analytics 订单中的订单表添加新过滤器和新字段
【发布时间】:2022-08-16 15:22:56
【问题描述】:

我需要向 woocommerce Analytics > Orders 页面添加两个新字段 一个过滤器和列到订单表

Filter Image

Order Column Image

  • 添加列需要帮助添加过滤器

标签: php wordpress woocommerce hook hook-woocommerce


【解决方案1】:

您可以添加新的自定义过滤器:


add_filter('woocommerce_admin_reports', 'woocommerce_admin_reports_new', 11, 1);

function woocommerce_admin_reports_new($report)
{
    $arra = array('title' => 'DESIGNER COMMISSION REPORT', 'description' => '', "hide_title" => 1,  "callback" =>  'get_report_for_designer_commission_report');
    $report['orders']['reports']['commission_report']  =  $arra;
    return $report;
  
}

function get_report_for_designer_commission_report()
{

//add your code here
}

//new field to orders table in Analytics orders

add_filter( 'manage_edit-shop_order_columns', 'register_is_first_order_column', 10, 1 );
function register_is_first_order_column( $columns ) {
    $columns['is_first_order'] = 'First order';
    return $columns;
}
 
add_action( 'manage_shop_order_posts_custom_column', 'display_is_first_order_column', 10, 1 );
function display_is_first_order_column( $column ) {
    global $post;
 
    if ( 'is_first_order' === $column ) {
        $is_first_order = get_post_meta( $post->ID, 'is_first_order', true );
        
        if ( false !== $is_first_order && strlen( $is_first_order ) > 0 ) {
            echo "✔️";
        }
    }
}

【讨论】:

  • 您好,不在 woocommerce > 报告页面中,我在分析 > 订单页面上需要它
猜你喜欢
  • 2022-01-10
  • 1970-01-01
  • 2022-01-20
  • 1970-01-01
  • 1970-01-01
  • 2020-12-30
  • 2022-07-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多