如何在WooCommerce获得今天的所有订单?

时间:2017-06-10 14:31:20

标签: wordpress woocommerce

我正在制作一个wordpress插件。 我想将所有woo商业订单数据提取到插件中。我能怎么做? 这不是我正在使用的正确方式。

$order = get_posts( array(
        'numberposts' => -1,
        'meta_key'    => '_customer_user',
        'post_type'   => wc_get_order_types(),
        'post_status' => array_keys( wc_get_order_statuses() ),
    ) );

    for($o=0;$o<count($order);$o++):
         $order_details = get_post_meta( $order[$o]->ID );
        $customer_name =  $order_details[_billing_first_name][0].' '.$order_details[_billing_last_name][0];
        $customer_phone =  $order_details[_billing_phone][0];
        $customer_email =  $order_details[_billing_email][0];
        $customer_city =  $order_details[_billing_city][0];
        $customer_state =  $order_details[_billing_state][0];
        $customer_state =  $order_details[_billing_state][0];
}

1 个答案:

答案 0 :(得分:0)

      $query_args = array(
            'fields' => 'ids',
            'post_type' => 'shop_order',
            'post_status' => array_keys( wc_get_order_statuses() ),
            'posts_per_page' => -1,
            //'numberposts' => -1,
            'date_query' => array(
                array(
                    'before' => $end_date, // replace desired date
                    'after'  => $start_date, // replace desired date
                    'inclusive' => true,
                ),
            ),
        );

        $query = new WP_Query($query_args);
相关问题