Users-Total-orders-list

get_results(“select p.ID as order_id, max( CASE WHEN pm.meta_key = ‘_billing_email’ and p.ID = pm.post_id THEN pm.meta_value END ) as billing_email, max( CASE WHEN pm.meta_key = ‘_shipping_first_name’ and p.ID = pm.post_id THEN pm.meta_value END ) as first_name, max( CASE WHEN pm.meta_key = ‘_shipping_last_name’ and p.ID = pm.post_id THEN pm.meta_value END ) as last_name, max( CASE WHEN pm.meta_key = ‘_shipping_address_1’ and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_address_1, max( CASE WHEN pm.meta_key = ‘_shipping_city’ and p.ID = pm.post_id THEN pm.meta_value END ) as city, max( CASE WHEN pm.meta_key = ‘_shipping_postcode’ and p.ID = pm.post_id THEN pm.meta_value END ) as postcode, max( CASE WHEN pm.meta_key = ‘_shipping_state’ and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_state, max( CASE WHEN pm.meta_key = ‘_order_total’ and p.ID = pm.post_id THEN pm.meta_value END ) as order_total, max( CASE WHEN pm.meta_key = ‘_paid_date’ and p.ID = pm.post_id THEN pm.meta_value END ) as paid_date, ( select group_concat( order_item_name separator ‘,  ‘ ) from wp_woocommerce_order_items where order_id = p.ID ) as order_items from wp_posts p join wp_postmeta pm on p.ID = pm.post_id join wp_woocommerce_order_items oi on p.ID = oi.order_id where post_type = ‘shop_order’ and post_date BETWEEN ‘2022-10-01’ AND ‘2029-12-31’ and post_status = ‘wc-completed’ group by p.ID ORDER BY `first_name` ASC, `paid_date` ASC “); echo ““; echo ““; $count = 0; foreach($result as $wp_posts){ $new = $wp_posts; if($new == 1){ if( $count > 0 ) echo ““; } $date = $wp_posts->paid_date; $dateVal = substr($date, 0, 10); echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; $count++; } echo ““; echo “
Order idNameEmailOrder_totalPaid date
“.$wp_posts->order_id.”“.$wp_posts->first_name.” “.$wp_posts->last_name.”“.$wp_posts->billing_email.”“.$wp_posts->order_total.”“.$dateVal.”
“.$wp_posts->order_items.”
“;

Users-Total-orders-list-2023

get_results(“select p.ID as order_id, max( CASE WHEN pm.meta_key = ‘_billing_email’ and p.ID = pm.post_id THEN pm.meta_value END ) as billing_email, max( CASE WHEN pm.meta_key = ‘_shipping_first_name’ and p.ID = pm.post_id THEN pm.meta_value END ) as first_name, max( CASE WHEN pm.meta_key = ‘_shipping_last_name’ and p.ID = pm.post_id THEN pm.meta_value END ) as last_name, max( CASE WHEN pm.meta_key = ‘_shipping_address_1’ and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_address_1, max( CASE WHEN pm.meta_key = ‘_shipping_city’ and p.ID = pm.post_id THEN pm.meta_value END ) as city, max( CASE WHEN pm.meta_key = ‘_shipping_postcode’ and p.ID = pm.post_id THEN pm.meta_value END ) as postcode, max( CASE WHEN pm.meta_key = ‘_shipping_state’ and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_state, max( CASE WHEN pm.meta_key = ‘_order_total’ and p.ID = pm.post_id THEN pm.meta_value END ) as order_total, max( CASE WHEN pm.meta_key = ‘_paid_date’ and p.ID = pm.post_id THEN pm.meta_value END ) as paid_date, ( select group_concat( order_item_name separator ‘,  ‘ ) from wp_woocommerce_order_items where order_id = p.ID ) as order_items from wp_posts p join wp_postmeta pm on p.ID = pm.post_id join wp_woocommerce_order_items oi on p.ID = oi.order_id where post_type = ‘shop_order’ and post_date BETWEEN ‘2023-01-01’ AND ‘2023-12-31’ and post_status = ‘wc-completed’ group by p.ID ORDER BY `first_name` ASC, `paid_date` ASC “); echo ““; echo ““; $count = 0; foreach($result as $wp_posts){ $new = $wp_posts; if($new == 1){ if( $count > 0 ) echo ““; } $date = $wp_posts->paid_date; $dateVal = substr($date, 0, 10); echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; $count++; } echo ““; echo “
Order idNameEmailOrder_totalPaid date
“.$wp_posts->order_id.”“.$wp_posts->first_name.” “.$wp_posts->last_name.”“.$wp_posts->billing_email.”“.$wp_posts->order_total.”“.$dateVal.”
“.$wp_posts->order_items.”
“;

Users-Total-orders-list-2024

get_results(“select p.ID as order_id, max( CASE WHEN pm.meta_key = ‘_billing_email’ and p.ID = pm.post_id THEN pm.meta_value END ) as billing_email, max( CASE WHEN pm.meta_key = ‘_shipping_first_name’ and p.ID = pm.post_id THEN pm.meta_value END ) as first_name, max( CASE WHEN pm.meta_key = ‘_shipping_last_name’ and p.ID = pm.post_id THEN pm.meta_value END ) as last_name, max( CASE WHEN pm.meta_key = ‘_shipping_address_1’ and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_address_1, max( CASE WHEN pm.meta_key = ‘_shipping_city’ and p.ID = pm.post_id THEN pm.meta_value END ) as city, max( CASE WHEN pm.meta_key = ‘_shipping_postcode’ and p.ID = pm.post_id THEN pm.meta_value END ) as postcode, max( CASE WHEN pm.meta_key = ‘_shipping_state’ and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_state, max( CASE WHEN pm.meta_key = ‘_order_total’ and p.ID = pm.post_id THEN pm.meta_value END ) as order_total, max( CASE WHEN pm.meta_key = ‘_paid_date’ and p.ID = pm.post_id THEN pm.meta_value END ) as paid_date, ( select group_concat( order_item_name separator ‘,  ‘ ) from wp_woocommerce_order_items where order_id = p.ID ) as order_items from wp_posts p join wp_postmeta pm on p.ID = pm.post_id join wp_woocommerce_order_items oi on p.ID = oi.order_id where post_type = ‘shop_order’ and post_date BETWEEN ‘2024-01-01’ AND ‘2024-12-31’ and post_status = ‘wc-completed’ group by p.ID ORDER BY `first_name` ASC, `paid_date` ASC “); echo ““; echo ““; $count = 0; foreach($result as $wp_posts){ $new = $wp_posts; if($new == 1){ if( $count > 0 ) echo ““; } $date = $wp_posts->paid_date; $dateVal = substr($date, 0, 10); echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; echo ““; $count++; } echo ““; echo “
Order idNameEmailOrder_totalPaid date
“.$wp_posts->order_id.”“.$wp_posts->first_name.” “.$wp_posts->last_name.”“.$wp_posts->billing_email.”“.$wp_posts->order_total.”“.$dateVal.”
“.$wp_posts->order_items.”
“;

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *