Monday, June 17, 2024
WoocommerceWordpress Tricks

Woocommerce get order total on daily basis

How to add download pdf link in woocommerce single product page?

Woocommerce get order total on daily basis

Hello to all, welcome to In this post, I am sharing the code for, how to get Woocommerce get order total on daily basis? 

Woocommerce is the best e-commerce plugin for shopping websites.

Here is the working code for Woocommerce get order total on daily basis:
// functions.php file code
function get_daily_purchases_total(){
    global $wpdb;

    return $wpdb->get_var( "
        SELECT DISTINCT SUM(pm.meta_value)
        FROM {$wpdb->prefix}posts as p
        INNER JOIN {$wpdb->prefix}postmeta as pm ON p.ID = pm.post_id
        WHERE p.post_type LIKE 'shop_order'
        AND p.post_status IN ('wc-processing','wc-completed')
        AND UNIX_TIMESTAMP(p.post_date) >= (UNIX_TIMESTAMP(NOW()) - (86400))
        AND pm.meta_key LIKE '_order_total'
    " );

//Use in template file:
<?php echo '<p>Total purchased of the day: ' . get_daily_purchases_total() . '</p>'; ?>

 If you have any query related to this post, then please comment or email me.

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.