<?php // Get Purchase order count last 24 hours In woocommerce
function get_purchase_order_count_last_24_hours() {
// Set up arguments for order query
$args = array(
'date_query' => array(
array(
'after' => date( 'Y-m-d', strtotime( '-1 day' ) ) // 24 hours ago
)
),
'status' => array( 'completed', 'processing' ),
'limit' => -1, // Get all orders
);
// Get orders with specified criteria
$orders = wc_get_orders( $args );
// Count the number of orders
$order_count = count( $orders );
return $order_count;
}
$purchase_order_count_last_24_hours = get_purchase_order_count_last_24_hours();
echo "There were $purchase_order_count_last_24_hours orders in the last 24 hours.";
?>