Title: Undefined function wc_get_order_statuses()
Last modified: November 24, 2021

---

# Undefined function wc_get_order_statuses()

 *  Resolved [nerosylius](https://wordpress.org/support/users/nerosylius/)
 * (@nerosylius)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/undefined-function-wc_get_order_statuses/)
 * Hello everyone,
    I would like to add some code that i’ve made in a custom plugin.
   It is working fine but the files are in the WordPress root folder. When I’m including
   these files as a plugin, I have an error on wc_get_order_status() function. Basically
   the function where it is called is just getting every order which have the processing
   status from the last 24h. I am just using wc_get_order_status() to get all statuses
   of Woocommerce and unset every statuses that I do no care about (completed for
   example) Thank you by advance.
 *     ```
       function get_orders_by_custom_date()
       {
           date_default_timezone_set('Europe/Paris');
           $now = strtotime('now');
           $today =  date("m/d/Y H:i:s", $now);
           $before_today = date('m/d/Y H:i:s', strtotime('-1 day'));
           $order_statuses = wc_get_order_statuses();
   
           unset($order_statuses['wc-pending']);    
           unset($order_statuses['wc-on-hold']);
           unset($order_statuses['wc-cancelled']);
           unset($order_statuses['wc-refunded']);
           unset($order_statuses['wc-failed']);
           // unset($order_statuses['wc-completed']);
   
           $query_args = array(
               'post_type'      => array('shop_order'),
               'post_status'    => array_keys($order_statuses),
               'posts_per_page' => -1,
               'date_query' => array(
                   'after'     => $before_today,
                   'before'    => $today,
               ),
           );
           $customer_orders = get_posts($query_args);
           return $customer_orders;
       }
       ```
   
    -  This topic was modified 4 years, 6 months ago by [nerosylius](https://wordpress.org/support/users/nerosylius/).
      Reason: Forgot the code

Viewing 1 replies (of 1 total)

 *  [MayKato](https://wordpress.org/support/users/maykato/)
 * (@maykato)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/undefined-function-wc_get_order_statuses/#post-15104125)
 * Hello,
 * This is a fairly complex development topic. I’m going to leave it open for a 
   bit to see if anyone is able to chime in to help you out.
 * I can also recommend [the WooCommerce Developer Resources Portal](https://developer.woocommerce.com/)
   for resources on developing for WooCommerce.
 * You can also visit the [WooCommerce Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
   or the `#developers` channel of the [WooCommerce Community Slack](https://woocommerce.com/community-slack/).

Viewing 1 replies (of 1 total)

The topic ‘Undefined function wc_get_order_statuses()’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [custom plugin](https://wordpress.org/support/topic-tag/custom-plugin/)

 * 1 reply
 * 2 participants
 * Last reply from: [MayKato](https://wordpress.org/support/users/maykato/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/undefined-function-wc_get_order_statuses/#post-15104125)
 * Status: resolved