• Resolved bowenac

    (@bowenac)


    Anyone know if it is possible to create an export that can group/distinct the results by a specific field? I’m trying to create an export that would include all woocommerce orders grouped by a specific custom order_meta field. e.g. order_affiliate.

    I would like this affiliate name to be the first column value… From there I could create custom functions for each of the remaining columns based on this initial value… Total Sales | Quantity Items Sold etc, where I could query in the custom function by the affiliate name to figure out the total sales by this specific affiliate.

    Another example output would be:
    Affiliate A
    Affiliate B
    Affiliate C

    Instead of:
    Affiliate A
    Affiliate B
    Affiliate A
    Affiliate C
    Affiliate A

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @bowenac,

    Anyone know if it is possible to create an export that can group/distinct the results by a specific field? I’m trying to create an export that would include all woocommerce orders grouped by a specific custom order_meta field. e.g. order_affiliate.

    If that’s a custom field attached to the orders you’re exporting (and not the products in the order), you could use WP_Query Results to specify the order: https://www.wpallimport.com/documentation/export/wp-query-results/.

    Here is an example query that you can modify as needed:

    'post_type' => 'shop_order',
    'post_status' => array( 'wc-completed','wc-pending','wc-processing' ),
    'meta_key' => 'affiliate_custom_field',
    'orderby' => 'meta_value',
    'order' => 'ASC'

    This example sorts the file in ascending order based on the value in the “affiliate_custom_field” custom field.

    Plugin Author WP All Import

    (@wpallimport)

    Hi @bowenac,

    I’m going to mark this as resolved since it’s been a while. You can follow up in this thread if you still have questions.

    Anyone else, please open a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Export orders grouped by a specific field?’ is closed to new replies.