-5

total number (#) of orders, maybe create the function in functions.php and call it in a shortcode anywhere in page. I just don't want to update it.

closed as off-topic by markratledge, Pieter Goosen, cybmeta, fuxia Nov 25 '14 at 23:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Third party plugins and themes are off topic here. – markratledge Nov 24 '14 at 1:07
  • 1
    Please, do not post the same question twice. You have been a long time member which should know by now, no duplicates and no support questions for third party plugins and themes. Please reread How to Ask. Thank you – Pieter Goosen Nov 24 '14 at 4:21
  • @PieterGoosen you understand people are asking third party plugin questions? Do you understand? Check all related questions songdogtech, you too. HYPOCRITES. – chris_r Nov 24 '14 at 18:05
  • 3
    Yes, that is why they get downvoted and closed. :-) – Pieter Goosen Nov 24 '14 at 18:13
  • 1
    If you have any more issues, please raise this in meta. Before you do, please read this first. Thank you :-) – Pieter Goosen Nov 24 '14 at 18:34
0

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 );
  • 2
    @wordpress_designer Please stay away from rude or offensive comments. Stay professional instead. Actually Pieter is right. Properly formatted code is a must on this site as questions do not only serve as quick answer, but as reference for later visitors. Instead of being rude you could have taken the time and just file an edit and fix the answer. Joined efforts are what drives a site like this one. Thanks for keeping that in mind for the future. – kaiser Nov 24 '14 at 18:26
  • I have properly formatted your code to make it more readable. Please keep in mind that the WYSIWYG is there to help you :-) – Pieter Goosen Nov 24 '14 at 18:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.