• I want to export a report that is has column one listing the product name, and column two listing all the customers who have ordered that product. For example:

    Product 1 | Doug, Jane, Cary
    Product 2 | Doug, Christoper
    Product 3 | Christopher, Jane, Stephanie

    Any way to do this? The only difference is instead of “User first name” we will use “User Billing Address”

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

    (@algolplus)

    Hello

    1. turn on checkbox “Summary report by products”
    2. follow to https://docs.algolplus.com/algol_order_export/add-calculated-field-for-product/

    add key customers_list

    use this code https://gist.github.com/alexv66/84e91ef89fb0933800b758f7773b4c57
    I think you must tweak it.
    $order is https://woocommerce.github.io/code-reference/classes/WC-Order.html

    • This reply was modified 3 months, 1 week ago by algol.plus.
    • This reply was modified 3 months, 1 week ago by algol.plus.
    • This reply was modified 3 months, 1 week ago by algol.plus.
    Thread Starter bluebuscreatives

    (@bluebuscreatives)

    This is great- I’m almost to where I need to be, I am using billing_address_1 as the field I’m grabbing. How can I get these to sort a-z in the column? Below is the code I’m currently using:

    add_action('woe_summary_products_add_item',function ($key, $item, $order) {
    $address = $order->get_billing_address_1();
    $address = str_replace(',',',',$address);
    if( empty($_SESSION['woe_summary_products'][$key]['customers_list']) )
    $_SESSION['woe_summary_products'][$key]['customers_list'] = $address;
    else
    $_SESSION['woe_summary_products'][$key]['customers_list'] .= "|" . $address;

    },10,3);

    We have the “billing_address_1” set as a suite number (this is for onsite catering). This is how it displays. I Would love for it to display in ascending, alphabetical order (note that there are suites with just numbers such as 201, 204, 301, and with letters and numbers like below, N9, N8, S2).

    N9|N8|N5|N2|N10

    Plugin Author algol.plus

    (@algolplus)

    please, adapt this code

    add_action('woe_summary_products_add_item',function ($key, $item, $order) {
    $address = $order->get_billing_address_1();
    $address = str_replace(',',',',$address);
    if( empty($_SESSION['woe_summary_products'][$key]['customers_list']) )
    $_SESSION['woe_summary_products'][$key]['customers_list'] = array();
    $_SESSION['woe_summary_products'][$key]['customers_list'] []= $address;
    },10,3);

    add_action('woe_summary_before_output' , function() {
    foreach($_SESSION['woe_summary_products'] as $key=>$data) {
    natsort($data['customers_list']);
    $_SESSION['woe_summary_products'][$key]['customers_list'] = join( "|", $data['customers_list']);
    }
    });

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.