Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Restrict WooCommerce Analytics to certain orders

I would like only certain orders to be taken into account in the whole Analytics Section. I found the "woocommerce_reports_get_order_report_data_args" filter, but I am having trouble making it work.

My orders have some meta data, which I set up using ACF. I wrote this snippet :

add_filter('woocommerce_reports_get_order_report_data_args', 'only_show_report_for_some_orders');
function only_show_report_for_some_orders( $args ) {
  $args['where_meta'] = array(
    'relation' => 'AND',
    array(
      'meta_key' => 'type_commande',
      'meta_value' => array('commande','sous-depot-vente'),
      'operator' => 'IN'
    ),
  );
  return $args;
}

I get one error in the console (Internal Server Error) and also, most of the analytics are displayed (but for all my orders), so I guess I am not using the right filter, and my use of the where_meta parameter might be wrong...

Thanks in advance!!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

add_filter('woocommerce_reports_get_order_report_data_args', 'woocommerce_reports_get_order_report_data_args');

function woocommerce_reports_get_order_report_data_args($args) {
    $args['where_meta'] = array(
        'meta_key' => 'type_commande',
        'operator' => 'in',
        'meta_value' => array('commande', 'sous-depot-vente')
    );
    return $args;
}

This is the hook you are looking for.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!