WooCommerce Total # orders [closed]

You can use this following query to get the total number of orders.

 $order_totals = apply_filters( 'woocommerce_reports_sales_overview_order_totals', $wpdb->get_row( "
    SELECT COUNT(posts.ID) AS total_orders FROM {$wpdb->posts} AS posts

    LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
    LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
    LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
    LEFT JOIN {$wpdb->terms} AS term USING( term_id )

    WHERE   meta.meta_key       = '_order_total'
    AND     posts.post_type="shop_order"
    AND     posts.post_status="publish"
    AND     tax.taxonomy        = 'shop_order_status'
    AND     term.slug           IN ('" . implode( "','", 
apply_filters( 'woocommerce_reports_order_statuses', 
array( 'completed', 'processing', 'on-hold' ) ) ) . "')
" ) );

$total_orders_count     = absint( $order_totals->total_orders );

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş