获取WooCommerce总销售美元金额(收入)

时间:2018-08-01 02:47:37

标签: wordpress woocommerce

反正有获取WooCommerce总销售金额的信息,我正在使用this plugin,它是为此的简码,但我正在寻找一种获取今天总收入金额的方法>(总销售)而不使用插件。我要在正在开发的另一个插件中使用该代码。

1 个答案:

答案 0 :(得分:0)

请尝试以下代码

    $Select_Order_Details = $wpdb->get_results( "SELECT SUM(meta.meta_value) AS total_sales, COUNT(posts.ID) AS total_orders FROM wp_posts AS posts

    LEFT JOIN wp_postmeta AS meta ON posts.ID = meta.post_id

    WHERE meta.meta_key = '_order_total'

    AND posts.post_type = 'shop_order'

    AND posts.post_status IN ( '" . implode( "','", array( 'wc-completed', 'wc-processing', 'wc-on-hold' ) ) . "' )");



    $Select_Order_Details = json_decode(json_encode($Select_Order_Details),true);
    print_r($Select_Order_Details);exit;