Purchase List Download as CSV

B2BKing Version 3.1 introduces the ability for users to download purchase lists as CSV files.

Purchase lists allow customers to save lists of items for later purchase / stock replenish / easy access.

These lists are saved in the user's account, and can be added to cart with a single click.

Since version 3.1 these lists can also be downloaded as CSV, with the item name, SKU, and quantity.

By clicking "Download" a CSV file will be downloaded with list details:

This functionality can help customers print lists, use them offline, or share these and discuss them with the shop.

How to add custom columns to purchase list CSV downloads #

You may want to add additional columns / download custom data in purchase lists CSVs. Here is an example where we add the stock quantity of a product as a new column.

To do that, add this PHP code snippet to your site:

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);	

After adding it you will see the new column has been added to downloads:

Powered by BetterDocs