WooCommerce B2B Sales Agents

Current version: 1.4.1



# Introduction
Get started with WooCommerce B2B Sales Agents, the best seller WordPress plugin to manage sales agents network.

WooCommerce B2B Sales Agents is a WordPress/WooCommerce extension that add to your website the capability to have sales agents and calculate their commissions.

In a single suite, all the features that an e-commerce can require to open its horizons to sales agents.

You can find an always updated version of this documentation here.

# Requirements
Before starting, check that you have the minimum characteristics to ensure the correct functioning of WooCommerce B2B Sales Agents.

  • WordPress: version 5.0 or above
  • WooCommerce: version 4.0 or above
  • PHP: version 5.6 or above
# Installation
There are multiple ways to install WooCommerce B2B Sales Agents, here is a quick step-by-step guide to do this.

Classic WordPress mode
  1. Login to your WordPress Dashboard
  2. Go to "Plugins > Add New" page
  3. Click "Upload Plugin" button at the top
  4. Select "woocommerce-b2b-sales-agents.zip" file and click "Install now" button
  5. Once installed, click "Activate" link
Manual mode
  1. Unzip "woocommerce-b2b-sales-agents.zip" file
  2. Login in your FTP area
  3. Upload the entire "woocommerce-b2b-sales-agents" folder to the "/wp-content/plugins/" directory
  4. Login in your WordPress site
  5. Go to "Plugins > Installed Plugins" page
  6. Click "Activate" link at WooCommerce B2B Sales Agents

Update

You can update WooCommerce B2B Sales Agents in several ways:

  • Classic WordPress mode: follow all steps described in previous paragraph relative to "Installation". After upload, please follow screen instuctions.
  • Manual mode: follow all steps described in previous paragraph relative to "Installation" and replace previous WooCommerce B2B Sales Agents plugin folder.
  • Envato Market mode: please look for third part plugin "Envato Market", download, install and configure it as described in its own page.

More informations in our FAQ "How do I update the plugin?".

Note: Don't uninstall the previous version! By uninstalling you will lose all plugin related settings.
Note: Before to update, please read carefully changelog and this documentation, to verify the changes of new release.
Note: Before to update to latest version, please be sure to have a complete backup (filesystem and database) to avoid any problems or errors.
Note: Before to update to latest version, please be sure to have a complete backup (filesystem and database) to avoid any problems or errors.

Update database process

By updating the plugin to a new release, you will be prompted to perform a database update.
This update is necessary for the correct functioning of the new release, so it is strongly recommended to do it.

All processes to be performed for the update are performed in the background and can be viewed in the WordPress section dedicated to scheduled actions:

Tools -> Scheduled Actions

and associated with the hook wcb2bsa_run_update_callback.


Note: Actions are added to the WordPress scheduler and run on a scheduled basis, depending on your cron settings, if any, so they may take some time to fully run. It is possible to force execution by clicking on the "Run" link next to each action.
# Quick start
Get started by using WooCommerce B2B Sales Agents by configuring your context.

  1. Configure general plugin options

    Define your store's behavior and rules by configuring WooCommerce B2B Sales Agents to your specific needs:

    WooCommerce -> Settings -> {Sales Agents tab}
    You can find more information on each individual option below in this documentation, in Plugin options section.
  2. Create sales agents you need

    Create one or more sales agents, depending on your project, choosing "Sales agent" in customer role dropdown:

    Users -> Add new
    Users -> All Users -> {Edit user profile}
    After the user has been created with "Sales agent" role, returning to his profile you will be able to see sales agent dedicated fields and options.
  3. Assign sales agent to customer

    Decide which sales agent to assign your customers to, in order to apply the rules configured for each of them. You can do this in several ways:


    • By individually assigning each customer to a sales agent in user profile edit page

      Users -> All Users -> {Edit user profile}

    • By massively assigning customers to a sales agent in user list

      Users -> All Users -> {Bulk actions}

    By default, WooCommerce B2B Sales Agents allows you to assign sales agents only to users with the predefined role "customer". If you want to extend this behavior to custom roles, take a look at the appropriate wcb2bsa_has_role_customer hook.
  4. Configure products

    For each product, you can apply specific rules. You can do this in several ways:


    • By individually settings each single product in product edit page

      Products -> All Products -> {Edit product}

    • By massively updating products using Import/Export tools

      Products -> All Products -> {Import/Export button}

    To know more about WooCommerce Import/Export tools, please read Official documentation.
  5. Choose sales agents dashboard page

    To configure the sales agent dashboard, simply have a WordPress page, with the shortcode [woocommerce_my_account] and select it in "SALES AGENTS DASHBOARD PAGE" dropdown option on the WooCommerce B2B Sales Agents settings page. You can do this in several ways:


    • By publishing default sales agents dashboard page

      Pages -> All Pages -> {Edit page}

    • By creating a new page to use as a sales agent dashboard

      Pages -> Add new

    By default, WooCommerce B2B Sales Agents generates a dedicated page that can be used as a sales agent dashboard and puts it in the "draft" status. You can use it by publishing it, or by creating a new one as you like.
# Plugin options
WooCommerce B2B Sales Agents introduces a large number of features, here a complete list with description to guide you in the configuration.

Main options
WooCommerce > Settings > Payments tab
WooCommerce > Settings > Emails tab

Waiting payment gateway and emails
Description

"Waiting payment" gateway is dedicated to sales agents and allows them to place "waiting payment" orders, that customers will pay later. The customer will receive an email with order details and a payment link and can decide to make the payment by clicking the "Pay" button directly from his my-account area.

Note: waiting payment email can be customized in WooCommerce settings page (Emails tab).
Note: waiting payment method text can be customized in WooCommerce settings page (Payments tab).
Screenshots

  • Checkout page
  • Waiting payment thankyou
  • Waiting payment myaccount
  • Waiting payment
    method customization
  • Waiting payment email
    customization
  • Waiting payment email

Settings page Settings
WooCommerce > Settings > Sales Agents > Settings tab

Moderate registration
Description

When a new sales agent register from dedicated dashboard page, it prevent autologin and sales agent can login only after administrator approval. On approval, sales agent receive an email notification which warns that his account is active.

Note: active account email can be customized in WooCommerce settings page (Emails tab).
Screenshots

  • Registration page
  • Active account email
  • New account email
  • Active account
    email customization
  • Admin user page
Registration notice
Description

Send email to admin on every new sales agent account registration. Very useful if moderate registration option is enabled.

Sales agent in emails
Description

Add sales agent data (name, email, phone) in transactional emails, to simplify the contact between the customer and the reference sales agent.

Screenshots

  • Processing order email
Sales agent in MyAccount
Description

Add sales agent data (name, email, phone) in customers MyAccount dashboard page, to simplify the contact between the customer and the reference sales agent.

Screenshots

  • My account page
Apply commission to
Description

Choose what to apply the commission to. By changing this option, only the next orders will be affected. You can customize this option for each order on order edit page.

Customization

You can customize redirect by using dedicated hooks:

Only direct orders
Description

Consider only orders placed directly from sales agent.

In his dashboard, sales agent can view only orders placed directly by him. Orders placed from his customers are excluded from counts, statistics, commissions calculation.

Edit customer data
Description

Allow sales agents to edit customer account and addresses data in checkout and in my-account pages when switched on his account.

Screenshots

  • Checkout page
  • Edit address page
Edit prices in cart
Description

Allow sales agents to edit and adjust product price in cart page when make purchase in behalf of their customers.

If you want, in each product you can set a minimum price, so the sales agent can change the price but without being able to go below the minimum price.

Screenshots

  • Cart page
  • Admin order page
Customization

You can customize cart price arguments input field by using dedicated hooks:

Orders commission column
Description

Add a new commissions column in WooCommerce orders list. In case of a large number of orders or on poorly performing servers, it may slow down the page loading, therefore it is advisable to disable this option in case of excessive slowdowns or out of memory problems in "WooCommerce -> Orders" page.

Screenshots

  • Admin orders page
Customization

You can customize cart price arguments input field by using dedicated hooks:

Default sales agent
Description

Assign automatically customer to a sales agent on registration. Also available these special options:

  • Random: assign a random sales agent among those available
  • Allow to choose: add a dropdown menu in checkout, so guest customers or customers without a sales agent can choose sales agent among those available

Screenshots

  • Checkout page
Estimated earnings
Description

For each product shows a box on the loop pages with an approximate calculation of commissions estimated earnings.

Screenshots

  • Product page
Stock availability
Description

When a sales agent purchase in behalf of customers, show stock availability in product list pages (loops).

Note: it requires "Manage stock" option in WooCommerce settings page (products -> inventory tab) is enabled.
Screenshots

  • Product page
Roles to consider as customer
Description

By default, WooCommerce B2B Sales Agents allows you to assign sales agents to users with the default role "customer". Optionally, choose which roles you want to extend this behavior to.

Note: Please be sure to have at least "customer" role selected.
Note: It's highly not recommended to remove the "customer" role from this list to prevent malfunctions.
Customization

You can customize roles by using dedicated hooks:

Roles to consider as sales agent
Description

By default, WooCommerce B2B Sales Agents allows you to assign commissions and access to dedicated dashboard to users with the default role "sales agent". Optionally, choose which roles you want to extend this behavior to.

Note: Please be sure to have at least "sales agent" role selected.
Note: It's highly not recommended to remove the "sales agent" role from this list to prevent malfunctions.
Customization

You can customize roles by using dedicated hooks:

Sales agents dashboard page
Description

Choose base page for your sales agents dashboard area.

On new installations, WooCommerce B2B Sales Agents automatically create a new page named "Sales agents dashboard" as draft with the proper shortcode [woocommerce_my_account]. To enable, simply publish it.

Screenshots

  • Sales agents dashboard
Customization

You can customize link to dashboard message by using dedicated hooks:

Enable affiliation
Description

Create an unique affiliation link (displayed in the sales agent dashboard) for each sales agents. When a customer uses the affiliate link to register an account, his profile will be assigned to the agent who owns used affiliate link.

Screenshots

  • Sales agent area
New subagents
Description

Allow sales agents to create new subagents, that will be automatically assigned to him.

Screenshots

  • Sales agent area
  • Sales agent area (modal)
Extended new subagent form
Description

Extends new subagent form adding checkout billing fields.

Note: all additional fields are considered not required. You can customize this behaviour by using proper hook.
Customization

You can customize redirect by using dedicated hooks:

Screenshots

  • Sales agent area
New customers
Description

Allow sales agents to create new customers, that will be automatically assigned to him.

Screenshots

  • Sales agent area
  • Sales agent area (modal)
Extended new customer form
Description

Extends new customer form adding checkout billing fields.

Note: all additional fields are considered not required. You can customize this behaviour by using proper hook.
Customization

You can customize redirect by using dedicated hooks:

Screenshots

  • Sales agent area
Update order status
Description

Allow sales agents to update their customers order status.

Screenshots

  • Sales agent area
  • Sales agent area (modal)
Add order note
Description

Allow sales agents to add note to their customers order.

Screenshots

  • Sales agent area
  • Sales agent area (modal)
Enable widgets
Description

Allow select widgets to enable and display to sales agents.

Here is a list of all available widgets:

  • Managed subagents number: number of sales agents that depend on current profile (subagents)
  • Managed customers number: total number of customers managed by current profile.
    NB: this number includes both direct customers and customers assigned to subagents
  • Total orders number: total number of orders managed by current profile.
    NB: this number includes both orders by direct customers and orders by customers assigned to subagents
  • Total orders value: total amount value of orders managed by current profile.
    NB: this amount includes both orders by direct customers and orders by customers assigned to subagents
  • Your earnings: total amount value of commissions virtually generated and assigned to current profile.
    NB: this amount includes only orders by direct customers and not orders by customers assigned to subagents NB: this amount doesn't indicate an actual and real profit, but only an assumed one, as it includes all commissions, regardless of the order status.
  • Your paid earnings: total amount value of commissions deemed valid and already paid.
    NB: this amount includes only orders by direct customers and not orders by customers assigned to subagents
  • Your pending earnings: total amount value of commissions deemed valid but not yet paid.
    NB: this amount includes only orders by direct customers and not orders by customers assigned to subagents
    NB: a commission is considered valid if order status is one of the following:
    • Completed
    • On hold
    • Pending
    • Processing
  • Current commission percentage: global commission percentage on orders from customers directly assigned to current profile.
  • Your subcommission earnings: total amount value of commissions virtually generated and assigned to current profile.
    NB: this amount includes only orders by customers assigned to subagents and not orders by direct customers NB: this amount doesn't indicate an actual and real profit, but only an assumed one, as it includes all commissions, regardless of the order status.
  • Your paid subcommission earnings: total amount value of commissions deemed valid and already paid.
    NB: this amount includes only orders by customers assigned to subagents and not orders by direct customers
  • Your pending subcommission earnings: total amount value of commissions deemed valid but not yet paid.
    NB: this amount includes only orders by customers assigned to subagents and not orders by direct customers
    NB: a commission is considered valid if order status is one of the following:
    • Completed
    • On hold
    • Pending
    • Processing
  • Current subcommission percentage: global commission percentage on orders from customers assigned to a subagent.
  • Total earnings: total amount value of commissions virtually generated and assigned to current profile.
    NB: this amount includes both orders by direct customers and orders by customers assigned to subagents (it's a sum of "Your earnings" and "Your subcommission earnings") NB: this amount doesn't indicate an actual and real profit, but only an assumed one, as it includes all commissions, regardless of the order status.
  • Total paid earnings: total amount value of commissions deemed valid and already paid.
    NB: this amount includes both orders by direct customers and orders by customers assigned to subagents (it's a sum of "Your paid earnings" and "Your paid subcommission earnings")
  • Total pending earnings: total amount value of commissions deemed valid but not yet paid.
    NB: this amount includes both orders by direct customers and orders by customers assigned to subagents (it's a sum of "Your pending earnings" and "Your pending subcommission earnings")
    NB: a commission is considered valid if order status is one of the following:
    • Completed
    • On hold
    • Pending
    • Processing
Screenshots

  • Sales agents dashboard
    (Manager)
  • Sales agents dashboard
    (Subagent)
Enable charts
Description

Allow select charts to enable and display to sales agents.

Screenshots

  • Sales agents dashboard
Endpoints settings
Description

Allow to change sales agents area endpoint slugs.


Settings page Status
WooCommerce > Settings > Sales agents > Status tab

Templates override
Description

Summary of templates status, with a list of templates overridden by your parent/child theme and a warning message that they need to be updated.

Screenshots

  • Status tab

User options
Users > All Users > {User}

Customer sales agent
Description

Assign a sales agent to customer.

Note: only for users with "customer" role.
Screenshots

  • Admin user page
Sales agent status
Description

Enable/Disable sales agent profile. If status is "Inactive", sales agent cannot login and work.

Note: it requires "Moderate registration" option in WooCommerce B2B Sales Agents settings page is enabled.
Screenshots

  • Admin user page
Affiliate ID
Description

Unique identifier that allows to recognize the sales agent and assign a customer who registers through affiliate link.

Note: only for users with "sales agent" role.
Screenshots

  • Admin user page
  • Sales agent area
Sales agent manager
Description

Build you sales agents hierarchy by assigning a sales agent manager.

Note: only for users with "sales agent" role.
Screenshots

  • Admin user page
Global commissions
Description

Assign a global commission to sales agent that will be apply on each purchase.

Note: only for users with "sales agent" role. Note: if product dedicated commission is set, it will override global commission on the product.
Screenshots

  • Admin user page
Global subcommissions
Description

Assign a global subcommission to sales agent that will be apply on each purchase by his subagent customers.

Note: only for users with "sales agent" role.
Screenshots

  • Admin user page
Send order notification
Description

If enabled, sales agent will receive new order notification when an assigned customer make a purchase.

Note: only for users with "sales agent" role.
Screenshots

  • Admin user page
Dashboard preferences
Description

Allows you to restrict the data used in orders and earnings list and in calculating the values of the widgets in the sales agents dashboard to specific time periods. Very useful in case of numerous orders to improve performance.

NB: this option not impact on all dashboard widgets and pages.
Screenshots

  • Admin user page
Payment preferences
Description

It allows you to make a note of the preferred payment method of the sales agent with the relevant data to make payments of the accrued commissions.

Note: only for users with "sales agent" role. Note: payments are not handled by the plugin, it is just additional information.
Customization

You can customize payment methods list by using dedicated hooks:

Screenshots

  • Admin user page

Order options
WooCommerce > Orders > {Order}

Order sales agent
Description

Assign or change order sales agent.

Screenshots

  • Admin order page
Apply commission to
Description

Choose or change what to apply the commission to.

Screenshots

  • Admin order page
Order created by
Description

When a new order is placed, WooCommerce B2B Sales Agents establishes whether the order was placed by admin, or directly by the customer, or by the sales agent on behalf of the customer. It is possible to change this data.

Screenshots

  • Admin order page

Product options
Products > All Products > {Product}

Product minimum price
Description

Set for each product a minimum price, so sales agent can change the price in cart but without being able to go below the minimum price.

Note: it requires "Edit prices in cart" option in WooCommerce B2B Sales Agents settings page (general tab) is enabled.
Screenshots

  • Admin product page
  • Cart page
Product dedicated commissions
Description

Set for each product custom commissions according to sales agent.

Screenshots

  • Admin product page

Coupon options
WooCommerce > Coupons > {Coupon}

Allowed sales agents
Description

Allow coupon usage to customers assigned to selected sales agents. No sales agents selected means no restrictions.

Screenshots

  • Admin coupons page

Import/Export tools
Products > All Products

Product Import/Export tools
Description

Bulk update product commissions. WooCommerce B2B Sales Agents extends default WooCommerce Import/Export tools to allow to fast manage its custom data.

Note: to know more about WooCommerce Import/Export tools, please read Official documentation.
Screenshots

  • Admin products page
  • Import page

WordPress Export tools
Tools > Export

Commissions export
Description

Allow to export commissions list in CSV file to statistics purposes.

Screenshots

  • Admin export tools page

WooCommerce reports
WooCommerce > Reports

Sales by sales agent
Description

Summarize sales grouped by sales agent, with total orders amount and total orders count.

Screenshots

  • Admin reports page

Customizer options
Appearance > Customize > WooCommerce B2B Sales Agents

Sales agents area logo
Description

You can upload your personal logo to display in sales agents area.

Screenshots

  • Admin customizer

Notification page
Users > Notifications > {Notification}

Notification
Description

Create all the notifications you want to communicate with your sales agents and notify them of new offers, discounts, coupons etc.

Each notification can be assigned to one or more sales agents.

Screenshots

  • Admin notification page

Commissions page
Users > Commissions

Commissions
Description

Here a filterable list of all commissions assigned to your sales agents.

You can set each commission as paid/unpaid to better manage your network.

Screenshots

  • Admin commissions page
# Bundle options (*)
WooCommerce B2B Sales Agents special features to improve compatibility and sinergy with WooCommerce B2B
(*) Note: these options will appear only if WooCommerce B2B plugin is installed and active.

Customer page
Users > All Users > {User}

Sales agent customers default group
Description

Assign automatically customer to a B2B group when sales agent register a new customer account. Also available these special options:

  • Allow to choose: add a dropdown menu in registration form, sales agents can choose group among those available

Screenshots

  • Admin user page
Group page
Users > All Groups > {Group}

Group commissions (*)
Description

Assign a group commission to sales agent that will be apply on each purchase when customer belong the group.

Note: if product dedicated commission is set, it will override group commission on the product.
Screenshots

  • Admin group page
# How to translate
Translate WooCommerce B2B Sales Agents is very simple.

WooCommerce B2B Sales Agents is already provided in two language: English and Italian.

All plugin strings have been localized using the GNU gettex framework to make it completely "translation ready", so it can be easly translated in the same way that other WordPress plugins.

Find out if WooCommerce B2B Sales Agents is available in your desired language, thanks to the collaboration of our fantastic users: Language packs.

You can translate WooCommerce B2B Sales Agents using special translation plugins, such as WPML for example. To know more about WPML configuration, take a look to: WooCommerce B2B Sales Agents compatibility with wpml.

This is a simple guide to translate WooCommerce B2B Sales Agents in the language of your choice without plugins.


Get a useful software: POEDIT

WordPress, with all its themes and plugins, based translations on GNU gettex framework, that use three types of files:

  • PO (Portable Object) files
  • MO (Machine Object) files
  • POT (Portable Object Template) files

The first step is to get a translation tool able to manage this kind of files; there are many ones available, but I suggest without doubt Poedit.

Poedit is a free open source software, easy to use and available for MacOSX, Windows, Linux and you can download it from here: https://poedit.net/download.


Translating with POEDIT

Create a new translation with Poedit is very simple, here a step-by-step guide to help you to make it.

  1. Install Poedit
  2. Open Poedit and go to:
    File -> New from POT/PO file
  3. In the popup box that appears, navigate into WooCommerce B2B Sales Agents folder and select the file:
    woocommerce-b2b-sales-agents/i18n/woocommerce-b2b-sales-agents.pot
  4. When the file is loaded, another box will pop up asking for the language you want to translate:
    Choose your language
  5. String by string, enter your translation in the Translate box at bottom.

When finished, validate your translation and save the file, named as: woocommerce-b2b-sales-agents-it_IT. The name pattern is composed by:

  • woocommerce-b2b-sales-agents: the plugin domain name, usually the plugin folder name (as described in WordPress i18n standards)
  • it: the GNU language code
  • IT: the GNU country code

Use your translation

After saving, Poedit will create two files:

  • woocommerce-b2b-sales-agents-it_IT.po
  • woocommerce-b2b-sales-agents-it_IT.mo

Your translations are ready! To use them, you just have to move them into the folder:

  • wp-content/languages/plugins/

Now, go to your website and WooCommerce B2B Sales Agents is finally translated in your language!


More informations

For more informations about language and country codes, please refer to:

For more informations about GNU gettex utilities and WordPress i18n, please refer to:

Note: if you want to contribute to WooCommerce B2B Sales Agents internationalization, please send your PO file to: support@woocommerce-b2b.com.
# Plugin Hooks
WooCommerce B2B Sales Agents provide large number of hooks to allow developers to extends or customize default behaviour.

If you are a developer, WooCommerce B2B Sales Agents give you many possible customizations by using the hooks. To know more about WordPress hooks working, please read Plugin API/Hooks WordPress Codex.

As WordPress best practice, we suggesto to make use of a WordPress Child Theme to avoid losing customizations in case of theme update. To know more about WordPress Child Theme, take a look to Child Themes WordPress Codex.

Here the list of WooCommerce B2B Sales Agents hooks:

Custom roles management
Description

WooCommerce B2B Sales Agents apply some own rules and functions only to default WooCommerce customer role and other functions only to sales_agent role. With this hook, you can extend these functions behaviour to custom roles.

Definition
apply_filters( 'wcb2bsa_has_role_customer', array $roles );
apply_filters( 'wcb2bsa_has_role_sales_agent', array $roles );
Defaults
$roles = array( 'customer' );
$roles = array( 'sales_agent' );
Example

To extend WooCommerce B2B Sales Agents sales agents role functions to a new custom role called "mycustomrole", you can add this code to your functions.php file:

add_filter( 'wcb2bsa_has_role_sales_agent', 'fn_wcb2bsa_has_role_sales_agent' );
function fn_wcb2bsa_has_role_sales_agent( $roles ) {
    $roles[] = 'mycustomrole';
    return $roles;
}
Dashboard widgets
Description

Customize sales agents dashboard by adding, modifying or removing widgets.

Definition
apply_filters( 'wcb2bsa_dashboard_widgets', array $widgets );
Example

To change "Current commission percentage" label, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_dashboard_widgets', 'fn_wcb2bsa_dashboard_widgets' );
function fn_wcb2bsa_dashboard_widgets( $widgets ) {
    $widgets['widgets']['current_commissions']['label'] = __( 'New label', 'woocommerce-b2b-sales-agents' );
    return $widgets;
}

To remove "Pending commission value" widget, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_dashboard_widgets', 'fn_wcb2bsa_dashboard_widgets' );
function fn_wcb2bsa_dashboard_widgets( $widgets ) {
    unset( $widgets['widgets']['pending_commissions'] );
    return $widgets;
}

Here available widgets and charts:

  • $widgets['widgets']['managed_subagents'] -> Managed subagents number
  • $widgets['widgets']['managed_customers'] -> Managed customers number
  • $widgets['widgets']['total_orders'] -> Total orders number
  • $widgets['widgets']['total_amount'] -> Total orders value
  • $widgets['widgets']['total_commissions'] -> Total direct commission value
  • $widgets['widgets']['paid_commissions'] -> Paid direct commission value
  • $widgets['widgets']['pending_commissions'] -> Pending direct commission value
  • $widgets['widgets']['current_commission'] -> Current commission percentage
  • $widgets['widgets']['total_subcommissions'] -> Total subcommission value
  • $widgets['widgets']['paid_subcommissions'] -> Paid subcommission value
  • $widgets['widgets']['pending_subcommissions'] -> Pending subcommission value
  • $widgets['widgets']['current_subcommission'] -> Current subcommission percentage
  • $widgets['widgets']['total_all_commissions'] -> Total commission value
  • $widgets['widgets']['paid_all_commissions'] -> Paid commission value
  • $widgets['widgets']['pending_all_commissions'] -> Pending commission value
  • $widgets['stats']['subagents'] -> Subagents chart
  • $widgets['stats']['customers'] -> Customers chart
  • $widgets['stats']['commissions'] -> Commissions chart
  • $widgets['stats']['orders'] -> Orders chart
Statistics
Description

Customize sales agents statistics parameters and data.

Definition
apply_filters( 'wcb2bsa_stats_params', array $params );
Example

To change chart bar (line) color, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_stats_params', 'fn_wcb2bsa_stats_params' );
function fn_wcb2bsa_stats_params( $params ) {
    $params['data']['datasets'][0]['backgroundColor'] = 'rgba( 255, 0, 0, 0.5 )';
    return $params;
}

To know more about parameters, please refer to: ChartJS documentation.

Interactive tables
Description

Interactive tables allow you to have advanced filters and export functions, but with a large amount of data they can cause slowdowns in page loading. With this hook you can disable interactive tables to improve performance.

Definition
apply_filters( 'wcb2bsa_enable_interactive_dashboard', boolean $enable );
Defaults
$enable = true
Example

To disable interactive tables, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_enable_interactive_dashboard', 'fn_wcb2bsa_enable_interactive_dashboard' );
function fn_wcb2bsa_enable_interactive_dashboard( $enable ) {
    return false;
}

Or, alternatively:

add_filter( 'wcb2bsa_enable_interactive_dashboard', '__return_false' );
CSS styles
Description

Customize sales agents area by adding, modifying or removing styles.

Definition
apply_filters( 'wcb2bsa_myaccount_styles', array $styles );
Example

To add a new style, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_myaccount_styles', 'fn_wcb2bsa_myaccount_styles' );
function fn_wcb2bsa_myaccount_styles( $styles ) {
    $styles['style-name'] = 'style-url';
    return $styles;
}

To remove "Font Awesome" style, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_myaccount_styles', 'fn_wcb2bsa_myaccount_styles' );
function fn_wcb2bsa_myaccount_styles( $styles ) {
    unset( $styles['fontawesome'] );
    return $styles;
}
JS styles
Description

Customize sales agents area by adding, modifying or removing scripts.

Definition
apply_filters( 'wcb2bsa_myaccount_scripts', array $scripts );
Example

To add a new script, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_myaccount_scripts', 'fn_wcb2bsa_myaccount_scripts' );
function fn_wcb2bsa_myaccount_scripts( $scripts ) {
    $scripts['script-name'] = 'script-url';
    return $scripts;
}

To remove "Chart JS" script, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_myaccount_scripts', 'fn_wcb2bsa_myaccount_scripts' );
function fn_wcb2bsa_myaccount_scripts( $scripts ) {
    unset( $scripts['chart'] );
    return $scripts;
}
Logo
Description

Customize sales agents area logo by replacing with a new one. This override logo inserted by WordPress customizer.

Definition
apply_filters( 'wcb2bsa_myaccount_logo_url', string $logo_url );
Example

To change logo, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_myaccount_logo_url', 'fn_wcb2bsa_myaccount_logo_url' );
function fn_wcb2bsa_myaccount_logo_url( $logo_url ) {
    return 'new-logo-url';
}
Menu items
Description

Customize sales agents area menu by managing items.

Definition
apply_filters( 'wcb2bsa_myaccount_menu_items', array $items );
Example

To add a new menu link in "Main" section, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_myaccount_menu_items', 'fn_wcb2bsa_myaccount_menu_items' );
function fn_wcb2bsa_myaccount_menu_items( $items ) {
    $items['main']['entries']['new-endpoint-slug'] = array(
        'label'     => __( 'Title', 'woocommerce-b2b-sales-agents' ),
        'icon'      => 'fas fa-icon'
    );
    return $items;
}

To remove an item from menu in "Profile" section, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_myaccount_menu_items', 'fn_wcb2bsa_myaccount_menu_items' );
function fn_wcb2bsa_myaccount_menu_items( $items ) {
    unset( $items['profile']['entries']['sales-agent-edit-account'] );
    return $items;
}

Here $items structure:

$items = array(
    'main' => array(
        'label'     => esc_html__( 'Main', 'woocommerce-b2b-sales-agents' ),
        'entries'   => array(
            'sales-agent-dashboard'     => array(
                'label'     => esc_html__( 'Dashboard', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-tachometer-alt'
            ),
            'sales-agent-customers'     => array(
                'label'     => esc_html__( 'Customers', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-users'
            ),
            'sales-agent-orders'        => array(
                'label'     => esc_html__( 'Orders', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-shopping-cart'
            ),
            'sales-agent-earnings'   => array(
                'label'     => esc_html__( 'Earnings', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-wallet'
            ),
            'sales-agent-commissions'   => array(
                'label'     => esc_html__( 'Commissions', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-percentage'
            ),
            'sales-agent-notifications'   => array(
                'label'     => esc_html__( 'Notifications', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-bell',
                'counter'   => wcb2bsa_get_notifications_count_by_sales_agent()
            ),
            'sales-agent-statistics'   => array(
                'label'     => esc_html__( 'Statistics', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-chart-bar'
            )
        )
    ),
    'network' => array(
        'label'     => esc_html__( 'Network', 'woocommerce-b2b-sales-agents' ),
        'entries'   => array(
            'sales-agent-subagents'     => array(
                'label'     => esc_html__( 'Subagents', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-user-tie'
            )
        )
    ),
    'profile' => array(
        'label'     => esc_html__( 'Profile', 'woocommerce-b2b-sales-agents' ),
        'entries'   => array(
            'sales-agent-edit-account'  => array(
                'label'     => esc_html__( 'Account', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'far fa-id-badge'
            ),
            'sales-agent-logout'        => array(
                'label'     => esc_html__( 'Logout', 'woocommerce-b2b-sales-agents' ),
                'icon'      => 'fas fa-sign-out-alt'
            )
        )
    )
);
Page templates
Description

Allow to have different myaccount page templates for customers and sales agents, by changing template search folder from 'woocommerce' to 'woocommerce-b2b-sales-agents'.

Definition
apply_filters( 'wcb2bsa_template_override_sales_agent', array $override );
Example

If you want to create a different template for new order email received by customer, when order is created by sales agent, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_template_override_sales_agent', 'fn_wcb2bsa_template_override_sales_agent' );
function fn_wcb2bsa_template_override_sales_agent( $override ) {
    $override[] = 'emails/customer-on-hold-order.php';
    return $override;
}

In this way:

  • if order is created by customer, "customer-on-hold-order.php" file used to generate email will located in {YOUR_THEME}/woocommerce/emails folder
  • if order is created by sales agent, "customer-on-hold-order.php" file used to generate email will located in {YOUR_THEME}/woocommerce-b2b-sales-agents/emails folder

So you can feel free to customize WooCommerce templates according to user role.

Empty cart on account switch
Description

When a sales agent switch on customer account, cart is emptied by default. However, it is possible to change this behavior, avoiding the removal of products previously placed in the cart by the customer.

Definition
apply_filters( 'wcb2bsa_empty_cart_on_switch', boolean $empty );
Defaults
$empty = true
Example

If you don't want to empty cart when a sales agent switch on customer account, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_empty_cart_on_switch', '__return_false' );
Switch to customer redirect
Description

Allow to set a custom page URL where redirect sales agents after they switch as customer.

Definition
apply_filters( 'wcb2bsa_switch_to_customer_redirect', string $permalink );
Example

If you want to redirect sales agents to homepage instead of shop page, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_switch_to_customer_redirect', 'fn_wcb2bsa_switch_to_customer_redirect' );
function fn_wcb2bsa_switch_to_customer_redirect( $permalink ) {
    return get_home_url();
}
Switch to sales agent redirect
Description

Allow to set a custom page URL where redirect sales agents after they switch from customer to return on their own area.

Definition
apply_filters( 'wcb2bsa_switch_to_sales_agent_redirect', string $permalink );
Example

If you want to redirect sales agents to customers page instead of dashboard, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_switch_to_sales_agent_redirect', 'fn_wcb2bsa_switch_to_sales_agent_redirect' );
function fn_wcb2bsa_switch_to_sales_agent_redirect( $permalink ) {
    return wc_get_endpoint_url( 'sales-agent-customers', '', wc_get_page_permalink( 'myaccount' ) );
}
Translating tables utilities
Description

To translate advanced tables labels (ie: "Search", "Export", "View", etc.), you first need to create a new folder (ie: wcb2bsa) in your theme folder (we suggest to create it in a child theme). Now, copy 'woocommerce-b2b-sales-agents/https://woocommerce-b2b.com/sales-agents/wp-content/docs/woocommerce-b2b-sales-agents/assets/vendor/datatables/i18n/en_US.json' file into this new folder and rename the file with your desired language code (ie: it_IT.json). Finally, edit this file and translare strings on right side. To have an example and know more about, please take a look to: DataTables internationalisation.

Definition
apply_filters( 'wcb2bsa_dt_i18n_folder', string $url );
Example

If you have: 'wp-content/themes/child-theme/wcb2bsa/xx_XX.json', you can add this code to your functions.php file:

add_filter( 'wcb2bsa_dt_i18n_folder', 'fn_wcb2bsa_dt_i18n_folder' );
function fn_wcb2bsa_dt_i18n_folder( $url ) {
    // https://www.example.com/wp-content/themes/child-theme/wcb2bsa/xx_XX.json
    return get_stylesheet_directory_uri() . '/wcb2bsa/' . get_locale() . '.json';
}

If you prefer, you can also insert a CDN or external URL to JSON translation file.

Get sales agent assigned subagents
Description

Customize sales agents assigned subagents list.

Definition
apply_filters( 'wcb2bsa_get_subagents_by_sales_agent_args', array $args, int $sales_agent_id );
Example

To exclude a specific user by ID, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_get_subagents_by_sales_agent_args', 'fn_wcb2bsa_get_subagents_by_sales_agent_args', 10, 2 );
function fn_wcb2bsa_get_subagents_by_sales_agent_args( $args, $sales_agent_id ) {
    $args['exclude'] = array( 10 );
    return $args;
}

To know more about $args allowed fields, please refer to WP_User_Query official documentation.

Get sales agent assigned customers
Description

Customize sales agents assigned customers list.

Definition
apply_filters( 'wcb2bsa_get_customers_by_sales_agent_args', array $args, int $sales_agent_id );
Example

To exclude a specific user by ID, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_get_customers_by_sales_agent_args', 'fn_wcb2bsa_get_customers_by_sales_agent_args', 10, 2 );
function fn_wcb2bsa_get_customers_by_sales_agent_args( $args, $sales_agent_id ) {
    $args['exclude'] = array( 10 );
    return $args;
}

To know more about $args allowed fields, please refer to WP_User_Query official documentation.

Get sales agent assigned orders
Description

Customize sales agents assigned orders list.

Definition
apply_filters( 'wcb2bsa_get_orders_by_sales_agent_args', array $args, int $sales_agent_id );
Example

To get orders with Direct bank transfer payment method, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_get_orders_by_sales_agent_args', 'fn_wcb2bsa_get_orders_by_sales_agent_args', 10, 2 );
function fn_wcb2bsa_get_orders_by_sales_agent_args( $args, $sales_agent_id ) {
    $args['payment_method'] = 'bacs';
    return $args;
}

To know more about $args allowed fields, please refer to WC_Order_Query official documentation.

Get sales agent assigned notifications
Description

Customize sales agents assigned notifications list.

Definition
apply_filters( 'wcb2bsa_get_notifications_by_sales_agent_args', array $args, int $sales_agent_id );
Example

To exclude a specific notification by ID, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_get_notifications_by_sales_agent_args', 'fn_wcb2bsa_get_notifications_by_sales_agent_args', 10, 2 );
function fn_wcb2bsa_get_notifications_by_sales_agent_args( $args, $sales_agent_id ) {
    $args['exclude'] = array( 10 );
    return $args;
}

To know more about $args allowed fields, please refer to WP_User_Query official documentation.

Pending commission calculation
Description

Decide which orders include in pending commission calculation by order status.

Definition
apply_filters( 'wcb2bsa_include_orders_in_pending_commissions_by_status', array $statuses, int $sales_agent_id );
Example

To remove "on-hold" orders from pending commission totals, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_include_orders_in_pending_commissions_by_status', 'fn_wcb2bsa_include_orders_in_pending_commissions_by_status', 10, 2 );
function fn_wcb2bsa_include_orders_in_pending_commissions_by_status( $statuses, $sales_agent_id ) {
    if ( ( $key = array_search( 'on-hold', $statuses ) ) !== false ) {
        unset( $statuses[$key] );
    }
    return $statuses;
}

Default statuses included in pending commission totals are:

  • completed
  • on-hold
  • pending
  • processing
Total commission calculation
Description

Decide which orders exclude in total orders amount calculation by order status.

Definition
apply_filters( 'wcb2bsa_exclude_orders_in_totals_by_status', array $statuses, int $sales_agent_id );
Example

To add "on-hold" orders in sales agent total orders amount, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_exclude_orders_in_totals_by_status', 'fn_wcb2bsa_exclude_orders_in_totals_by_status', 10, 2 );
function fn_wcb2bsa_exclude_orders_in_totals_by_status( $statuses, $sales_agent_id ) {
    $statuses[] = 'on-hold';
    return $statuses;
}

Default statuses excluded in sales agent total orders amount are:

  • cancelled
  • failed
  • refunded
Items eligible for commission
Description

You can choose to don't apply a commission to order item type in WooCommerce B2B Sales Agents settings page, but if you install a third part plugin that add some custom item types in orders, you you may want apply sales agents commission on these new items.

Definition
apply_filters( 'wcb2bsa_order_item_types_eligible_for_commission', array $items );
Example

To add a new item type in setting eligible items for commission, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_order_item_types_eligible_for_commission', 'fn_wcb2bsa_order_item_types_eligible_for_commission' );
function fn_wcb2bsa_order_item_types_eligible_for_commission( $items ) {
    $items['item-slug'] = __( 'Item name', woocommerce-b2b-sales-agents );
    return $items;
}

Default items are those provided by WooCommerce:

  • Products
  • Fees
  • Shipping costs
Cart price input field arguments
Description

Customize price input field added in cart page by changing arguments.

Definition
apply_filters( 'wcb2bsa_cart_input', array $args );
Defaults
$args = array(
    'class' => 'input-text text',
    'min'   => '0',
    'step'  => '0.01'
);
Example

To add a custom class to improve your theme compatibility, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_cart_input', 'fn_wcb2bsa_cart_input' );
function fn_wcb2bsa_cart_input( $args ) {
    $args['class'] .= ' my-custom-class';
    return $args;
}
Affiliate base URL
Description

Lets you edit the link to the affiliation landing page.

Definition
apply_filters( 'wcb2bsa_affiliate_baseurl', string $url );
Example

To change URL, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_affiliate_baseurl', 'fn_wcb2bsa_affiliate_baseurl' );
function fn_wcb2bsa_affiliate_baseurl( $url ) {
    // https://www.example.com/my-registration-page, Page ID 100 
    return get_the_permalink( 100 );
}
Affiliate permalink parameter name
Description

Lets you change URL parameter name in affiliate link.

Definition
apply_filters( 'wcb2bsa_affiliate_parameter', string $parameter );
Defaults
$parameter = 'wcb2bsa_affiliate';
Example

To change URL parameter, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_affiliate_parameter', 'fn_wcb2bsa_affiliate_parameter' );
function fn_wcb2bsa_affiliate_parameter( $parameter ) {
    return 'custom_parameter_name';
}
Sales agent statuses
Description

Customize sales agent status to improve account moderation management.

Note: it requires "Moderate registration" option in WooCommerce B2B Sales Agents settings page is enabled.
Definition
apply_filters( 'wcb2bsa_sales_agent_statuses', array $statuses );
Defaults
$statuses = array(
    0 => esc_html__( 'Inactive', 'woocommerce-b2b-sales-agents' ),
    1 => esc_html__( 'Active', 'woocommerce-b2b-sales-agents' )
);
Example

To add a custom status, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_sales_agent_statuses', 'fn_wcb2bsa_sales_agent_statuses' );
function fn_wcb2bsa_sales_agent_statuses( $statuses ) {
    $statuses[3] = esc_html__( 'Pending', 'woocommerce-b2b-sales-agents' );
    return $statuses;
}
Send sales agent account activation email
Description

Send an email notification to sales agent when his account is activated.

Note: it requires "Moderate registration" option in WooCommerce B2B Sales Agents settings page is enabled.
Definition
apply_filters( 'wcb2bsa_send_activation_notification', bool $send );
Defaults
$send = true;
Example

To don't send any email notification to sales agent when his account his active, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_send_activation_notification', 'fn_wcb2bsa_send_activation_notification' );
function fn_wcb2bsa_send_activation_notification( $send ) {
    return false;
}

Or, alternatively:

add_filter( 'wcb2bsa_send_activation_notification', '__return_false' );
Sales Agents area new subagent form fields
Description

Used to manage new subagent form fields when extended form is enabled.

Definition
apply_filters( 'wcb2bsa_new_subagent_form_fields', array $fields );
Example

To make phone number required, you can add this code to your functions.php file:

add_action( 'wcb2bsa_new_subagent_form_fields', 'fn_wcb2bsa_new_subagent_form_fields' );
function fn_wcb2bsa_new_subagent_form_fields( $fields ) {
    $fields['billing_phone']['required'] = true;
    return $fields;
}

To remove phone field in extended form, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_new_subagent_form_fields', 'fn_wcb2bsa_new_subagent_form_fields' );
function fn_wcb2bsa_new_subagent_form_fields( $fields ) {
    unset( $fields['billing_phone'] );
    return $fields;
}

This hook works similarly to WooCommerce's default "woocommerce_billing_fields" hook, but only affects the new customer form in sales agents dashboard. To know more about "woocommerce_billing_fields" hook, please read: Customizing checkout fields using actions and filters.

Sales Agents area new subagent form fields arguments
Description

Used to manage new subagent form fields arguments to customize fields.

Definition
apply_filters( 'wcb2bsa_new_subagent_form_fields_args', array $args );
Example

To apply a custom class to new subagent form fields container, you can add this code to your functions.php file:

add_action( 'wcb2bsa_new_subagent_form_fields_args', 'fn_wcb2bsa_new_subagent_form_fields_args' );
function fn_wcb2bsa_new_subagent_form_fields_args( $args ) {
    $args['class'] = array( 'my_custom_class' );
    return $args;
}

To know more about $args allowed fields, please refer to Hook description.

Sales Agents area new subagent form
Description

Triggered in sales agents dedicated area in new subagent form modal.

Definition
do_action( 'wcb2bsa_new_subagent_form' );
Example

To add a new callback, you can add this code to your functions.php file:

add_action( 'wcb2bsa_new_subagent_form', 'fn_wcb2bsa_new_subagent_form' );
function fn_wcb2bsa_new_subagent_form() {
    // Make action magic happen here...
}
Sales Agents area new customer form fields
Description

Used to manage new customer form fields when extended form is enabled.

Definition
apply_filters( 'wcb2bsa_new_customer_form_fields', array $fields );
Example

To make phone number required, you can add this code to your functions.php file:

add_action( 'wcb2bsa_new_customer_form_fields', 'fn_wcb2bsa_new_customer_form_fields' );
function fn_wcb2bsa_new_customer_form_fields( $fields ) {
    $fields['billing_phone']['required'] = true;
    return $fields;
}

To remove phone field in extended form, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_new_customer_form_fields', 'fn_wcb2bsa_new_customer_form_fields' );
function fn_wcb2bsa_new_customer_form_fields( $fields ) {
    unset( $fields['billing_phone'] );
    return $fields;
}

This hook works similarly to WooCommerce's default "woocommerce_billing_fields" hook, but only affects the new customer form in sales agents dashboard. To know more about "woocommerce_billing_fields" hook, please read: Customizing checkout fields using actions and filters.

Sales Agents area new customer form fields arguments
Description

Used to manage new customer form fields arguments to customize fields.

Definition
apply_filters( 'wcb2bsa_new_customer_form_fields_args', array $args );
Example

To apply a custom class to new customer form fields container, you can add this code to your functions.php file:

add_action( 'wcb2bsa_new_customer_form_fields_args', 'fn_wcb2bsa_new_customer_form_fields_args' );
function fn_wcb2bsa_new_customer_form_fields_args( $args ) {
    $args['class'] = array( 'my_custom_class' );
    return $args;
}

To know more about $args allowed fields, please refer to Hook description.

Sales Agents area new customer form
Description

Triggered in sales agents dedicated area in new customer form modal.

Definition
do_action( 'wcb2bsa_new_customer_form' );
Example

To add a new callback, you can add this code to your functions.php file:

add_action( 'wcb2bsa_new_customer_form', 'fn_wcb2bsa_new_customer_form' );
function fn_wcb2bsa_new_customer_form() {
    // Make action magic happen here...
}
Sales agents payment methods
Description

Manage payment methods available list for sales agents.

Definition
apply_filters( 'wcb2bsa_payment_methods', array $methods );
Defaults
$methods = array(
    'paypal' => __( 'Paypal', 'woocommerce-b2b-sales-agents' ),
    'bankwire' => __( 'Bankwire', 'woocommerce-b2b-sales-agents' )
);
Example

To add another payment method, you can add this code to your functions.php file:

add_action( 'wcb2bsa_payment_methods', 'fn_wcb2bsa_payment_methods' );
function fn_wcb2bsa_payment_methods( $methods ) {
    $methods['custom_payment_method'] = __( 'Custom payment method', 'woocommerce-b2b-sales-agents' );
    return $methods;
}

To remove a payment method, you can add this code to your functions.php file:

add_action( 'wcb2bsa_payment_methods', 'fn_wcb2bsa_payment_methods' );
function fn_wcb2bsa_payment_methods( $methods ) {
    unset( $methods['paypal'] );
    return $methods;
}
Admin commission page args
Description

Manage query arguments in admin commissions list.

Note: on servers with low performance or in the case of heavy databases, setting too many results per page can cause slowdowns or errors.
Definition
apply_filters( 'wcb2bsa_admin_commissions_page_args', $args );
Example

To show 50 rows, you can add this code to your functions.php file:

add_action( 'wcb2bsa_admin_commissions_page_args', 'fn_wcb2bsa_admin_commissions_page_args' );
function fn_wcb2bsa_admin_commissions_page_args( $args ) {
    $args['limit'] = 50;
    return $args;
}

To know more about $args allowed fields, please refer to Documentation.

Add subagents orders/customer to sales agents lists
Description

If true, allow sales agent to see his own subagents orders and customers data in dashboard lists.

Definition
apply_filters( 'wcb2bsa_subagents_full_hierarchy', true );
Example

To disallow all sales agents to add subagents orders/customers, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_subagents_full_hierarchy', 'fn_wcb2bsa_subagents_full_hierarchy' );
function fn_wcb2bsa_subagents_full_hierarchy( $allow ) {
    return false;
}

Or, alternatively:

add_filter( 'wcb2bsa_subagents_full_hierarchy', '__return_false' );
Allow sales agents to read subagents data
Description

If true, allow sales agent to see his own subagents orders and customers data.

Definition
apply_filters( 'wcb2bsa_subagents_hierarchy_readable', true );
Example

To disallow sales agents to see subagents orders/customers, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_subagents_hierarchy_readable', 'fn_wcb2bsa_subagents_hierarchy_readable' );
function fn_wcb2bsa_subagents_hierarchy_readable( $allow ) {
    return false;
}

Or, alternatively:

add_filter( 'wcb2bsa_subagents_hierarchy_readable', '__return_false' );
Allow sales agents to edit subagents data
Description

If true, allow sales agent to edit his own subagents orders and customers data. If false, for example, sales agents cannot change his subagents orders status or add note.

Definition
apply_filters( 'wcb2bsa_subagents_hierarchy_writable', true );
Example

To disallow sales agents to edit subagents orders/customers, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_subagents_hierarchy_writable', 'fn_wcb2bsa_subagents_hierarchy_writable' );
function fn_wcb2bsa_subagents_hierarchy_writable( $allow ) {
    return false;
}

Or, alternatively:

add_filter( 'wcb2bsa_subagents_hierarchy_writable', '__return_false' );
WooCommerce B2B Sales Agents generator tag
Description

Output generator tag in website head to aid debugging.

Definition
apply_filters( 'wcb2bsa_show_generator_tag', boolean $show );
Defaults
$show = true;
Example

To remove generator tag, you can add this code to your functions.php file:

add_filter( 'wcb2bsa_show_generator_tag', 'fn_wcb2bsa_show_generator_tag' );
function fn_wcb2bsa_show_generator_tag( $show ) {
    return false;
}

Or, alternatively:

add_filter( 'wcb2bsa_show_generator_tag', '__return_false' );
WooCommerce B2B Sales Agents before init
Description

Triggered when WordPress initialises.

Definition
do_action( 'wcb2bsa_before_init' );
Example

To add a new callback, you can add this code to your functions.php file:

add_action( 'wcb2bsa_before_init', 'fn_wcb2bsa_before_init' );
function fn_wcb2bsa_before_init() {
    // Make action magic happen here...
}
WooCommerce B2B Sales Agents init
Description

Triggered after plugin has initialized.

Definition
do_action( 'wcb2bsa_init' );
Example

To add a new callback, you can add this code to your functions.php file:

add_action( 'wcb2bsa_init', 'fn_wcb2bsa_init' );
function fn_wcb2bsa_init() {
    // Make action magic happen here...
}
WooCommerce B2B Sales Agents loaded
Description

Triggered when plugin has loaded.

Definition
do_action( 'wcb2bsa_loaded' );
Example

To add a new callback, you can add this code to your functions.php file:

add_action( 'wcb2bsa_wcb2bsa_loaded', 'fn_wcb2bsa_loaded' );
function fn_wcb2bsa_loaded() {
    // Make action magic happen here...
}
Sales Agents area print styles
Description

Triggered in sales agents dedicated area to print styles.

Definition
do_action( 'wcb2bsa_print_styles' );
Example

To add a new callback, you can add this code to your functions.php file:

add_action( 'wcb2bsa_print_styles', 'fn_wcb2bsa_print_styles' );
function fn_wcb2bsa_print_styles() {
    // Make action magic happen here...
}
Sales Agents area print script
Description

Triggered in sales agents dedicated area to print scripts.

Definition
do_action( 'wcb2bsa_print_scripts' );
Example

To add a new callback, you can add this code to your functions.php file:

add_action( 'wcb2bsa_print_scripts', 'fn_wcb2bsa_print_scripts' );
function fn_wcb2bsa_print_scripts() {
    // Make action magic happen here...
}
# REST API support
Manage WooCommerce B2B Sales Agents data with extended REST API.

WooCommerce B2B Sales Agents is perfect integrated and extends default WooCommerce REST API to manage its own custom fields.

For more informations, please visit: WordPress Official documentation

Note: alias fields are provided only in GET response, to manage WooCommerce B2B Sales agents additional data in PUT or POST methods please refer to default meta data management as described in WooCommerce official documentation


Product API
Description

This API lets you retrieve and view all products or a specific product by ID.

WooCommerce B2B Sales Agents available meta fields:

  • wcb2bsa_min_price: contains product minimum price allowed to sales agents when they edit prices in cart.
    Value is a floating number
    In API GET response, has also a dedicated field alias named "wcb2bsa_min_price"
  • wcb2bsa_commissions: contains dedicated commissions by sales agent.
    Value is an associative array with SALES AGENT ID as key and commission percentage as value (it's a floating number).
    In API GET response, has also a dedicated field alias named "wcb2bsa_commissions"

Note: WooCommerce B2B Sales Agents extends default WooCommerce products REST API with own custom meta fields. For more informations, please visit: WooCommerce Official documentation


HTTP request (all products)
get
/wp-json/wc/v3/products

HTTP request (single product)
get
/wp-json/wc/v3/products/{ID}

Example response
{
    "id": 60,
    "name": "T-Shirt with Logo",
    "slug": "t-shirt-with-logo",
    "permalink": "https://demo.woocommerce-b2b.com/product/t-shirt-with-logo/",
    "date_created": "2020-06-13 00:00:00",
    "date_created_gmt": "2020-06-13 00:00:00",
    "date_modified": "2020-06-13 00:00:00",
    "date_modified_gmt": "2020-06-13 00:00:00",
    "type": "simple",
    "status": "publish",
    "featured": false,
    "catalog_visibility": "visible",
    "description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
    "short_description": "<p>This is a simple product.</p>\n",
    "sku": "Woo-tshirt-logo",
    "price": "98",
    "regular_price": "100",
    "sale_price": "98",
    "date_on_sale_from": null,
    "date_on_sale_from_gmt": null,
    "date_on_sale_to": null,
    "date_on_sale_to_gmt": null,
    "price_html": "<del><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">$</span>100.00</span></del> <ins><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">$</span>98.00</span></ins>",
    "on_sale": true,
    "purchasable": true,
    "total_sales": 0,
    "virtual": false,
    "downloadable": false,
    "downloads": [],
    "download_limit": 0,
    "download_expiry": 0,
    "external_url": "",
    "button_text": "",
    "tax_status": "taxable",
    "tax_class": "",
    "manage_stock": false,
    "stock_quantity": null,
    "stock_status": "instock",
    "backorders": "no",
    "backorders_allowed": false,
    "backordered": false,
    "sold_individually": false,
    "weight": "",
    "dimensions": {
        "length": "10",
        "width": "12",
        "height": "0.5"
    },
    "shipping_required": true,
    "shipping_taxable": true,
    "shipping_class": "",
    "shipping_class_id": 0,
    "reviews_allowed": true,
    "average_rating": "0.00",
    "rating_count": 0,
    "related_ids": [
        50,
        40,
        43,
        51
    ],
    "upsell_ids": [],
    "cross_sell_ids": [],
    "parent_id": 0,
    "purchase_note": "",
    "categories": [
        {
            "id": 20,
            "name": "Tshirts",
            "slug": "tshirts-clothing"
        }
    ],
    "tags": [],
    "images": [
        {
            "id": 83,
            "date_created": "2020-06-13 00:00:00",
            "date_created_gmt": "2020-06-13 00:00:00",
            "date_modified": "2020-06-13 00:00:00",
            "date_modified_gmt": "2020-06-13 00:00:00",
            "src": "https://demo.woocommerce-b2b.com/wp-content/uploads/2020/06/t-shirt-with-logo-1.jpg",
            "name": "t-shirt-with-logo-1.jpg",
            "alt": ""
        }
    ],
    "attributes": [
        {
            "id": 1,
            "name": "Color",
            "position": 0,
            "visible": true,
            "variation": false,
            "options": [
                "Gray"
            ]
        }
    ],
    "default_attributes": [],
    "variations": [],
    "grouped_products": [],
    "menu_order": 0,
    "meta_data": [
        {
            "id": 967,
            "key": "_wpcom_is_markdown",
            "value": "1"
        },
        {
            "id": 3156,
            "key": "wcb2bsa_commissions",
            "value": {
                "9": "10"
            }
        },
        {
            "id": 3157,
            "key": "wcb2bsa_min_price",
            "value": "80"
        }
    ],
    "wcb2bsa_commissions": [
        {
            "9": 10
        }
    ],
    "wcb2bsa_min_price": "80",
    "_links": {
        "self": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/products/60"
            }
        ],
        "collection": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/products"
            }
        ]
    }
}
Customer API
Description

This API lets you retrieve and view all customers or a specific customer by ID.

WooCommerce B2B Sales Agents available meta fields:

  • wcb2bsa_status: contains sales agent status (if moderate registration is enabled).
    Value can be 0 (=disabled) or 1 (=enabled)
    In API GET response, has also a dedicated field alias named "wcb2bsa_status"
  • wcb2bsa_affiliate_id: contains unique affiliation code used for customer assignment (only for sales agents).
    Value is a string
    In API GET response, has also a dedicated field alias named "wcb2bsa_affiliate_id"
  • wcb2bsa_affiliate_link: contains sales agent unique affiliation link (only for sales agents).
    Value is a URL
    In API GET response, has also a dedicated field alias named "wcb2bsa_affiliate_link"
  • wcb2bsa_sales_agent_parent: contains assigned manager sales agent ID (only for sales agents).
    Value is an integer number
    In API GET response, has also a dedicated field alias named "wcb2bsa_sales_agent_parent"
  • wcb2bsa_commission: contains global commission percentage (only for sales agents).
    Value is a floating number
    In API GET response, has also a dedicated field alias named "wcb2bsa_commission"
  • wcb2bsa_subcommission: contains global subcommission percentage (only for sales agents).
    Value is a floating number
    In API GET response, has also a dedicated field alias named "wcb2bsa_subcommission"
  • wcb2bsa_order_notification: contains order notification status (only for sales agents).
    Value can be 0 (=disabled) or 1 (=enabled)
    In API GET response, has also a dedicated field alias named "wcb2bsa_order_notification"
  • wcb2bsa_dashboard_period: contains period to consider for dashboard data (only for sales agents).
    Value can be:
    • "e": Ever
    • "d": Today
    • "w": Current week
    • "m": Current month
    • "y": Current year

    In API GET response, has also a dedicated field alias named "wcb2bsa_dashboard_period"
  • wcb2bsa_payment_method: contains sales agent preferred payment method (only for sales agents).
    Value is a string
    In API GET response, has also a dedicated field alias named "wcb2bsa_payment_method"
  • wcb2bsa_payment_method_info: contains sales agent preferred payment method info note (only for sales agents).
    Value is a string
    In API GET response, has also a dedicated field alias named "wcb2bsa_payment_method_info"
  • wcb2bsa_parents: contains parent sales agent ID (only for sales agents).
    Value is an array with parent sales agents IDs
    In API GET response, has also a dedicated field alias named "wcb2bsa_sales_agent"
  • wcb2bsa_subagents: contains subagents sales agent IDs (only for sales agents).
    Value is an array with subagents IDs
    In API GET response, has also a dedicated field alias named "wcb2bsa_subagents"
  • wcb2bsa_customers_default_group: contains default group assigned to customers registered by sales agent (only for sales agents / Only if WooCommerce B2B is installed).
    Value is an integer number or a string ("choose")
    In API GET response, has also a dedicated field alias named "wcb2bsa_customers_default_group"
  • wcb2bsa_sales_agent: contains assigned sales agent ID (only for customers).
    Value is an integer number
    In API GET response, has also a dedicated field alias named "wcb2bsa_sales_agent"

Note: WooCommerce B2B Sales Agents extends default WooCommerce products REST API with own custom meta fields. For more informations, please visit: WooCommerce Official documentation


HTTP request (all customers)
get
/wp-json/wc/v3/customers

HTTP request (single customer)
get
/wp-json/wc/v3/customers/{ID}

Example response (customer)
{
    "id": 2,
    "date_created": "2020-06-13T00:00:0",
    "date_created_gmt": "2020-06-13T00:0:0",
    "date_modified": "2020-06-13T00:00:00",
    "date_modified_gmt": "2020-06-13T00:00:00",
    "email": "customer@woocommerce-b2b.com",
    "first_name": "John",
    "last_name": "Doe",
    "role": "customer",
    "username": "customer",
    "billing": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "Google LLC",
        "address_1": "Central Park, 1",
        "address_2": "",
        "city": "New York",
        "postcode": "10001",
        "country": "US",
        "state": "NY",
        "email": "customer@woocommerce-b2b.com",
        "phone": "212-223-6457"
    },
    "shipping": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "Google LLC",
        "address_1": "Central Park, 1",
        "address_2": "",
        "city": "New York",
        "postcode": "10001",
        "country": "US",
        "state": "NY"
    },
    "is_paying_customer": true,
    "avatar_url": "https://secure.gravatar.com/avatar/25c626881bff6847aa6efc0820f01ec5?s=96&d=mm&r=g",
    "meta_data": [
        {
            "id": 62,
            "key": "wc_last_active",
            "value": "1592092800"
        },
        {
        "id": 353,
            "key": "shipping_method",
            "value": [
                "flat_rate:2"
            ]
        },
        {
            "id": 880,
            "key": "wcb2bsa_sales_agent",
            "value": "9"
        }
    ],
    "wcb2bsa_sales_agent": 9,
    "_links": {
        "self": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/customers/2"
            }
        ],
        "collection": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/customers"
            }
        ]
    }
}

Example response (sales agent)
{
    "id": 3,
    "date_created": "2020-06-13T00:00:0",
    "date_created_gmt": "2020-06-13T00:0:0",
    "date_modified": "2020-06-13T00:00:00",
    "date_modified_gmt": "2020-06-13T00:00:00",
    "email": "sales@woocommerce-b2b.com",
    "first_name": "Jane",
    "last_name": "Doe",
    "role": "sales_agent",
    "username": "sales",
    "billing": {
        "first_name": "Jane",
        "last_name": "Doe",
        "company": "Google LLC",
        "address_1": "Central Park, 1",
        "address_2": "",
        "city": "New York",
        "postcode": "10001",
        "country": "US",
        "state": "NY",
        "email": "sales@woocommerce-b2b.com",
        "phone": "212-223-6457",
        "vat_number": "0987654321"
    },
    "shipping": {
        "first_name": "Jane",
        "last_name": "Doe",
        "company": "Google LLC",
        "address_1": "Central Park, 1",
        "address_2": "",
        "city": "New York",
        "postcode": "10001",
        "country": "US",
        "state": "NY"
    },
    "is_paying_customer": true,
    "avatar_url": "https://secure.gravatar.com/avatar/25c626881bff6847aa6efc0820f01ec5?s=96&d=mm&r=g",
    "meta_data": [
        {
            "id": 62,
            "key": "wc_last_active",
            "value": "1592092800"
        },
        {
            "id": 848,
            "key": "wcb2bsa_status",
            "value": "1"
        },
        {
            "id": 878,
            "key": "wcb2bsa_affiliate_id",
            "value": "c2FsZXNAd29vY29tbWVyY2UtYjJiLmNvbXwz"
        },
        {
            "id": 910,
            "key": "wcb2bsa_affiliate_link",
            "value": "https://demo.woocommerce-b2b.com/sales-agents/my-account/?wcb2bsa_affiliate=c2FsZXNAd29vY29tbWVyY2UtYjJiLmNvbXwxNA="
        },
        {
            "id": 880,
            "key": "wcb2bsa_commission",
            "value": "10"
        },
        {
            "id": 881,
            "key": "wcb2bsa_subcommission",
            "value": "5"
        },
        {
            "id": 890,
            "key": "wcb2bsa_order_notification",
            "value": "0"
        },
        {
            "id": 891,
            "key": "wcb2bsa_dashboard_period",
            "value": "m"
        },
        {
            "id": 353,
            "key": "wcb2bsa_payment_method",
            "value": "paypal"
        },
        {
            "id": 354,
            "key": "wcb2bsa_payment_method_info",
            "value": "Payment email: sales@paypal.com"
        },
        {
            "id": 900,
            "key": "wcb2bsa_customers_default_group",
            "value": "74"
        },
        {
            "id": 903,
            "key": "wcb2bsa_sales_agent_parent",
            "value": "32"
        },
        {
            "id": 904,
            "key": "wcb2bsa_subagents",
            "value": [
                "44",
                "46",
                "77"
            ]
        }
    ],
    "wcb2bsa_status": "1",
    "wcb2bsa_affiliate_id": "c2FsZXNAd29vY29tbWVyY2UtYjJiLmNvbXwz",
    "wcb2bsa_affiliate_link": "https://demo.woocommerce-b2b.com/sales-agents/my-account/?wcb2bsa_affiliate=c2FsZXNAd29vY29tbWVyY2UtYjJiLmNvbXwxNA=",
    "wcb2bsa_commission": "10",
    "wcb2bsa_subcommission": "5",
    "wcb2bsa_order_notification": "0",
    "wcb2bsa_dashboard_period": "m",
    "wcb2bsa_payment_method": "paypal",
    "wcb2bsa_payment_method_info": "Payment email: sales@paypal.com",
    "wcb2bsa_customers_default_group": 74,
    "wcb2bsa_parents": [
        "32"
    ],
    "wcb2bsa_subagents": [
        "44",
        "46",
        "77"
    ],
    "_links": {
        "self": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/customers/3"
            }
        ],
        "collection": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/customers"
            }
        ]
    }
}
Order API
Description

This API lets you retrieve and view all orders or a specific order by ID.

WooCommerce B2B Sales Agents available meta fields:

  • wcb2bsa_sales_agent: contains assigned sales agent ID when order placed.
    Value is an integer number
    In API GET response, has also a dedicated field alias named "wcb2bsa_sales_agent"
  • wcb2bsa_order_item_types_eligible_for_commission: contains item types on which commissions can be applied and calculated when order placed.
    Value is an associative array with ITEM TYPE as key and enabled flag as value (it's a tinyint number, 0 (=disabled) or 1 (=enabled)).
    In API GET response, has also a dedicated field alias named "wcb2bsa_order_item_types_eligible_for_commission"
  • wcb2bsa_created_by: contains who created the order.
    Value is a string, can be "customer", "sales_agent", "admin"
    In API GET response, has also a dedicated field alias named "wcb2bsa_created_by"

Each "line_items" contains specific meta fields:

  • wcb2bsa_item_commission: contains single item percentage commission when order placed.
    Value is an floating number
  • wcb2bsa_custom_price: contains if item price has been altered and customized by sales agent in cart when order placed.
    Value is a boolean

Note: WooCommerce B2B Sales Agents extends default WooCommerce products REST API with own custom meta fields. For more informations, please visit: WooCommerce Official documentation


HTTP request (all orders)
get
/wp-json/wc/v3/orders

HTTP request (single order)
get
/wp-json/wc/v3/orders/{ID}

Example response
{
    "id": 101,
    "parent_id": 0,
    "number": "101",
    "order_key": "wc_order_AZ59JpOFpEQcv",
    "created_via": "checkout",
    "version": "4.3.0",
    "status": "completed",
    "currency": "USD",
    "date_created": "2020-06-13T02:00:0",
    "date_created_gmt": "2020-06-13T00:00:0",
    "date_modified": "2020-06-13T02:00:0",
    "date_modified_gmt": "2020-06-13T00:00:0",
    "discount_total": "0.00",
    "discount_tax": "0.00",
    "shipping_total": "20.00",
    "shipping_tax": "4.40",
    "cart_tax": "51.12",
    "total": "307.90",
    "total_tax": "55.52",
    "prices_include_tax": true,
    "customer_id": 2,
    "customer_ip_address": "***",
    "customer_user_agent": "***",
    "customer_note": "",
    "billing": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "Google LLC",
        "address_1": "Central Park, 1",
        "address_2": "",
        "city": "New York",
        "state": "NY",
        "postcode": "10001",
        "country": "US",
        "email": "customer@woocommerce-b2b.com",
        "phone": "2122236457"
    },
    "shipping": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "Google LLC",
        "address_1": "Central Park, 1",
        "address_2": "",
        "city": "New York",
        "state": "NY",
        "postcode": "10001",
        "country": "US"
    },
    "payment_method": "bacs",
    "payment_method_title": "Direct bank transfer",
    "transaction_id": "",
    "date_paid": "2020-06-13T02:00:0",
    "date_paid_gmt": "2020-06-13T00:00:0",
    "date_completed": "2020-06-13T02:00:0",
    "date_completed_gmt": "2020-06-13T00:00:0",
    "cart_hash": "4c4d2a2498f758a949a05f83a439b8e5",
    "meta_data": [
        {
            "id": 1068,
            "key": "wcb2bsa_sales_agent",
            "value": "3"
        },
        {
            "id": 1069,
            "key": "wcb2bsa_order_item_types_eligible_for_commission",
            "value": {
                "line_item": "1",
                "fee": "1",
                "shipping": "1"
            }
        },
        {
            "id": 1487,
            "key": "wcb2bsa_created_by",
            "value": "sales_agent"
        }
    ],
    "line_items": [
        {
            "id": 9,
            "name": "Hoodie - Blue, Yes",
            "product_id": 12,
            "variation_id": 35,
            "quantity": 7,
            "tax_class": "",
            "subtotal": "232.38",
            "subtotal_tax": "51.12",
            "total": "232.38",
            "total_tax": "51.12",
            "taxes": [
                {
                    "id": 1,
                    "total": "51.12",
                    "subtotal": "51.12"
                }
            ],
            "meta_data": [
                {
                    "id": 82,
                    "key": "pa_color",
                    "value": "blue",
                    "display_key": "Color",
                    "display_value": "Blue"
                },
                {
                    "id": 83,
                    "key": "logo",
                    "value": "Yes",
                    "display_key": "Logo",
                    "display_value": "Yes"
                },
                {
                    "id": 84,
                    "key": "wcb2bsa_item_commission",
                    "value": "10",
                    "display_key": "wcb2bsa_item_commission",
                    "display_value": "10"
                },
                {
                    "id": 1933,
                    "key": "wcb2bsa_custom_price",
                    "value": "true",
                    "display_key": "wcb2bsa_custom_price",
                    "display_value": "true"
                }
            ],
            "sku": "woo-hoodie-blue-logo",
            "price": 33.19672128571428,
            "parent_name": "Hoodie"
        }
    ],
    "tax_lines": [
        {
            "id": 11,
            "rate_code": "TAX-1",
            "rate_id": 1,
            "label": "Tax",
            "compound": false,
            "tax_total": "51.12",
            "shipping_tax_total": "4.40",
            "rate_percent": 22,
            "meta_data": [
                {
                    "id": 98,
                    "key": "wcb2bsa_item_commission",
                    "value": "10",
                    "display_key": "wcb2bsa_item_commission",
                    "display_value": "10"
                }
            ]
        }
    ],
    "shipping_lines": [
        {
            "id": 10,
            "method_title": "Flat rate",
            "method_id": "flat_rate",
            "instance_id": "2",
            "total": "20.00",
            "total_tax": "4.40",
            "taxes": [
                {
                    "id": 1,
                    "total": "4.4",
                    "subtotal": ""
                }
            ],
            "meta_data": [
                {
                    "id": 90,
                    "key": "Products",
                    "value": "Hoodie - Blue, Yes × 7",
                    "display_key": "Products",
                    "display_value": "Hoodie - Blue, Yes × 7"
                },
                {
                    "id": 91,
                    "key": "wcb2bsa_item_commission",
                    "value": "10",
                    "display_key": "wcb2bsa_item_commission",
                    "display_value": "10"
                }
            ]
        }
    ],
    "fee_lines": [],
    "coupon_lines": [],
    "refunds": [],
    "currency_symbol": "$",
    "wcb2bsa_sales_agent": 3,
    "wcb2bsa_order_item_types_eligible_for_commission": {
        "line_item": "1",
        "fee": "1",
        "shipping": "1"
    },
    "wcb2bsa_created_by": "sales_agent",
    "_links": {
        "self": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/orders/101"
            }
        ],
        "collection": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/orders"
            }
        ],
        "customer": [
            {
                "href": "https://demo.woocommerce-b2b.com/sales-agents/wp-json/wc/v3/customers/2"
            }
        ]
    }
}

For more informations about REST API, please take a look to WooCommerce Official documentation.

# Templates customization
WooCommerce B2B Sales Agents templates can be override to customize as you prefer.

Templates override

WooCommerce B2B Sales Agents make use of same WooCommerce override system, so it's possible to create own templates and customize them.

Here a list of WooCommerce B2B Sales Agents templates that can be customized:

  • templates/email/customer-waiting-order.php: email received from customers when a new order with waiting payment is created by sales agent.
  • templates/email/email-sales-agent.php: sales agent data to include in customer emails.
  • templates/email/sales_agent-status-notification.php: email received from sales agent when his account is active.
  • templates/global/breadcrumb.php: sales agents area breadcrumb
  • templates/global/footer.php: sales agents area footer
  • templates/global/header.php: sales agents area header
  • templates/global/pagination.php: sales agents area pagination (when interactive tables are disabled)
  • templates/global/sidebar.php: sales agents area sidebar
  • templates/global/switchbar.php: customer switchbar to return to sales agent profile
  • templates/loop/estimated-earnings.php: sales agent approximate estimated earnings for product
  • templates/loop/stock.php: product stock availability
  • templates/myaccount/commissions.php: sales agents area commissions list
  • templates/myaccount/earnings.php: sales agents area earnings list
  • templates/myaccount/subagents.php: sales agents area subagents list
  • templates/myaccount/customers.php: sales agents area customers list
  • templates/myaccount/dashboard.php: sales agents area dashboard
  • templates/myaccount/edit-account.php: sales agents area edit account profile
  • templates/myaccount/my-account.php: sales agents area main page
  • templates/myaccount/notifications.php: sales agents area notifications list
  • templates/myaccount/orders.php: sales agents area orders list
  • templates/myaccount/sales-agent-data.php: sales agents data in customer MyAccount dashboard page
  • templates/myaccount/statistics.php: sales agents area statistics list
  • templates/myaccount/view-subagent.php: sales agents area single subagent page
  • templates/myaccount/view-customer.php: sales agents area single customer page
  • templates/myaccount/view-order.php: sales agents area single order page
  • templates/myaccount/form-new-subagent.php: sales agents area form modal to add new subagent in subagents list page
  • templates/myaccount/form-new-customer.php: sales agents area form modal to add new customer in customers list page
  • templates/myaccount/form-add-order-note.php: sales agents area form modal to add order note in single order details page
  • templates/myaccount/form-update-order-status.php: sales agents area form modal to update order status in single order details page
  • templates/notices/error.php: sales agents area error notification
  • templates/notices/notice.php: sales agents area notice notification
  • templates/notices/success.php: sales agents area success notification
How to override a template
  1. Copy the default template from:
    wp-content/plugins/woocommerce-b2b-sales-agents/templates/{TEMPLATE_PATH}
    and paste it in your theme folder at:
    wp-content/themes/{YOUR_ACTIVE_THEME}/woocommerce-b2b-sales-agents/
    preserving the same folder tree.
  2. Open the template you pasted into the theme folder with a text editor of choice and perform any changes that you want in your new template file.

To know more about this kind of system, take a look to Template structure & Overriding templates via a theme.

How to update templates overrides

Sometimes we update default templates when a new version of WooCommerce B2B is released. If you are using older templates, you may need to update them.

  1. Go to: WooCommerce > Settings > Sales Agents > Status. Here there is a list of templates overridden by your theme/child theme and a warning message that they need to be updated.

    • Status tab
  2. Save a backup of the outdated template.
  3. Copy the default template from:
    wp-content/plugins/woocommerce-b2b-sales-agents/templates/{TEMPLATE_PATH}
    and paste it in your theme folder at:
    wp-content/themes/{YOUR_ACTIVE_THEME}/woocommerce-b2b-sales-agents/
    preserving the same folder tree.
  4. Open the template you pasted into the theme folder with a text editor of choice and replicate any changes that you had to the previous template in your new, updated template file.
# Pluggable functions
WooCommerce B2B Sales Agents provide large number of pluggable functions to allow developers to extends or customize default behavior.

If you are a developer, WooCommerce B2B Sales Agents give you many possible customizations by using the pluggable functions. To know more about WordPress pluggable functions working, please read Pluggable Functions WordPress Codex.

As WordPress best practice, we suggesto to make use of a WordPress Child Theme to avoid losing customizations in case of theme update. To know more about WordPress Child Theme, take alook to Child Themes WordPress Codex.

All WooCommerce B2B Sales Agents pluggable functions are contained into the file:

  • wp-content/plugins/woocommerce-b2b-sales-agents/includes/wcb2bsa-functions.php
# Compatibility
Take a look to most common compatibility adjusts about WooCommerce B2B Sales Agents with other plugins or themes.

WooCommerce B2B Sales Agents make use of standard WooCommerce hooks and best practice to warranty a great compatibility with themes or third part plugins.

However, in some cases, there may be minor incompatibilities that need minor adjustments.

As WordPress best practice, we suggesto to make use of a WordPress Child Theme to avoid losing customizations in case of theme update. To know more about WordPress Child Theme, take alook to Child Themes WordPress Codex.

Here are the known ones.


WPML plugin
Description

To know more about WPML configuration, take a look to: WooCommerce B2B Sales Agents compatibility with wpml.

This is a simple guide to configure WooCommerce B2B Sales Agents and WPML to work in the best way.

SiteGround Optimizer
Description

In some cases, the SiteGround Optimizer plugin can cause problems with the display of the sales agent dashboard or user myaccount page due to a suboptimal plugin configuration.

Solution

To resolve, it is sufficient to exclude the URLs of the myaccount page and the sales agent dashboard page from caching, through the SiteGround Optimizer settings:

SG Optimizer -> Caching -> Caching Settings section -> Exclude URLs from Caching



In some cases, a deeper intervention is needed, which can be performed using WordPress hooks and functions that SiteGround Optimizer makes available.

To resolve, it is sufficient to force cache clearing of these pages on login, you can add this code to your functions.php file:

add_action( 'wp_login', 'wcb2bsa_clear_sgcachepress', 10, 2 );
function wcb2bsa_clear_sgcachepress( $user_login, $user ) {
    if ( function_exists( 'sg_cachepress_purge_cache' ) ) {
        sg_cachepress_purge_cache( get_permalink( get_option( 'wcb2bsa_dashboard_page' ) ) ); // Dashboard
        sg_cachepress_purge_cache( get_permalink( wc_get_page_id( 'myaccount' ) ) ); // MyAccount
    }
}
# Frequently Asked Questions
Take a look to users most common questions and learn more about WooCommerce B2B Sales Agents.

Take advantage of other users experience, by reading our FAQs

# Changelog
What's new in latest WooCommerce B2B Sales Agents version?

Here all the versions of WooCommerce B2B Sales Agents: Changelog

# Support
Need help with WooCommerce B2B Sales Agents and you cannot find the solution in documentation?

Thanks for purchasing WooCommerce B2B Sales Agents plugin for WordPress/WooCommerce, proudly developed by @code4life, visit the author website.

If you have any kind of question or doubt, please visit new WooCommerce B2B Support Center, we'll do our best to assist you.

WooCommerce B2B support team