Okay
  Public Ticket #3303957
Add metadata to purchase list CSV
Closed

Comments

  • Dan started the conversation

    Want to add additional product data to the purchase list CSV. The data is imported as metadata. I cant find the file that controls the template that generates the CSV.

  •  2,218
    WebWizards replied

    Hello Dan,

    Thank you for purchasing our plugin,


    The function that controls the purchase list CSV download is b2bkingdownloadpurchaselist() in class-b2bking.php


    There are 2 hooks there through which you can add a custom product column. I wrote a snippet example:

    add_filter('b2bking_list_download_columns_header', function($columns){
        array_push($columns, 'Stock quantity');
        return $columns;
    }, 10, 1);
    add_filter('b2bking_list_download_columns_items', function($data, $list_item){
        
        $item = explode(':', $list_item);
        $product_id = $item[0];
        $stock_quantity = get_post_meta($product_id, '_stock', true);
        array_push($data, $stock_quantity);
        return $data;
    }, 10, 2);
    

    This can be added to your site's functions.php or to any snippets plugin.

    It will add a "Stock quantity" column there.


    3010875295.png



    Kind regards,

    Stefan