Purchase List Download as CSV

Purchase Lists Feature #

B2BKing's purchase lists feature allows customers to save a purchase list or requisition list for later use. Customers can save lists of frequently purchased items for purposes such as stock replenishment. These lists are added to each customer's "My Account" area and can be added to the cart with a single click.

Purchase List Example

Download Lists as CSV #

In B2BKing 3.1, we introduced a new feature that allows you to download any list as a CSV file. These CSV downloads include the 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 overall 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 or download custom data in purchase list 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 this, 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 this snippet, you will see that 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 format "purchase_list_123.csv," where 123 is the unique ID of each list.

You can change the base "purchase_list" text to anything you 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