• Resolved kidkilowatt

    (@kidkilowatt)


    Hi, how can I export orders sorted by Billing Name instead of by Order ID, Order Date, or Modified Date.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    hi

    Could you try this code ?

    // sort by billing full name using SQL filters
    add_filter('woe_sql_get_order_ids_left_joins', function ($joins) {
    	global $wpdb;
    	$joins[] = "LEFT JOIN {$wpdb->postmeta} AS billing_last ON (billing_last.post_id = orders.ID AND billing_last.meta_key='_billing_last_name')";
    	$joins[] = "LEFT JOIN {$wpdb->postmeta} AS billing_first ON (billing_first.post_id = orders.ID AND billing_first.meta_key='_billing_first_name')";
    	return $joins;
    });
    
    add_filter('woe_sql_get_order_ids_fields', function ($fields) {
     	return "ID AS order_id, CONCAT(billing_first.meta_value,billing_last.meta_value) AS billing_name";
    });
    
    add_filter('woe_sql_get_order_ids_order_by', function ($order_by) {
    	return "ORDER BY billing_name";
    });
    Thread Starter kidkilowatt

    (@kidkilowatt)

    PERFECT!!! Many, many thanks!

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort Orders by Billing Name’ is closed to new replies.