Purchase List Download as CSV

Purchase Lists Feature #

B2BKing's purchase lists feature allows customers to save a purchase list / requisition list for later use. Customers could save lists of frequently purchased items for purposes such as stock replenishment. These lists are added to customers' "my account" area and can be added to cart with a single click.

Purchase List Example

Download Lists as CSV #

In B2BKing 3.1 we introduce a new feature that allows downloading any list as a CSV file. These CSV downloads include item name, SKU, quantity, and price, but additional columns can also be added.

This feature enables customers to save their purchase lists for future reference. They can conveniently print these lists, access them offline, or share and discuss them with the shop, enhancing their shopping experience.

How to Download

To download a list, customers can go to their My Account section -> Purchase lists, and use the "Download" button next to each list.

Purchase Lists Page Showing All Lists

After clicking download, a CSV file will be downloaded, similar to the following example:

Purchase list CSV file opened with the Numbers app

Add Custom Columns to Purchase List CSVs #

You may want to add additional columns / download custom data in purchase lists CSVs. This can be achieved through code snippets. 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:

How to Change the Default File Name #

The default name of the CSV file will have the form "purchase_list_123.csv" where 123 is the unique ID of each list.

You can change the base "purchase_list" text to anything else you would like, by adding the following PHP code snippet to your site:

add_filter('b2bking_purchase_list_file_name', function($list_name){
	return 'custom_name_here';
}, 10, 1);

After adding the above code, the same list will have the name "custom_name_here_123.csv".

Powered by BetterDocs