【发布时间】:2022-08-16 15:22:56
【问题描述】:
-
添加列需要帮助添加过滤器
标签: php wordpress woocommerce hook hook-woocommerce
标签: php wordpress woocommerce hook hook-woocommerce
您可以添加新的自定义过滤器:
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 "✔️";
}
}
}
【讨论】: