Quick Orders via CSV Upload

Introduced in B2BKing v3.1.0, the Quick Orders via CSV feature is a quick way for customers to add products to cart by uploading a 2-column CSV file with columns for SKU and Quantity.

This functionality should not be confused with the Bulk / Wholesale Order Form.

Quick CSV Order Form

Order Form Shortcode #

The CSV order form can be set up by adding the [b2bking_csvorder] shortcode to any page.

The form will accept a CSV file that has SKU numbers on the first column, and quantity on the second column, such as the following file:

The plugin parses the entire CSV, but only looks at the first 2 columns. Everything else will be ignored. The plugin will check if the first item in a row is a valid SKU and if not, ignore that row. The example above is a valid example, as the header row would be ignored (because the first element in the row is not a valid SKU)

Add Order Form to My Account #

You may want to also add this form to the my account page, as in the following image:

To achieve this, you can add the following PHP code snippet to the site:

function b2bking_add_csv_order_endpoint() {
    add_rewrite_endpoint( 'csv-order', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'b2bking_add_csv_order_endpoint' );
   
function b2bking_csv_order_query_vars( $vars ) {
    $vars[] = 'csv-order';
    return $vars;
}
  
add_filter( 'query_vars', 'b2bking_csv_order_query_vars', 0 );
function b2bking_add_csv_order_link_my_account( $items ) {
    $last_item = $items['customer-logout'];
    unset($items['customer-logout']);
    $items['csv-order'] = 'CSV Orders';
    $items['customer-logout'] = $last_item;
    return $items;
}
add_filter( 'woocommerce_account_menu_items', 'b2bking_add_csv_order_link_my_account', 1000000 );
  
function b2bking_csv_order_content() {
   echo '<h2>Quick CSV Order</h2>';
   echo do_shortcode( '[b2bking_csvorder]' );
}
add_action( 'woocommerce_account_csv-order_endpoint', 'b2bking_csv_order_content' );

Powered by BetterDocs