Buy B2BKing
$299 $199
B2BKing introduces Subaccounts as a way to provide a multiple buyers per account system.
Starting with B2BKing 4.7.0, the main account can click to log in as each subaccount:
If you would like to disable this feature, you can add the following snippet to your site:
add_filter('b2bking_allow_subaccount_login','__return_false');
In B2B e-commerce, companies often need multiple employees to have access to a single account—to view prices, place orders, communicate with the rest of the team, and more.
These employees may or may not need permission to access various features within the account. For instance, a company may want a user to have access to the catalog and prices but not have permission to place orders.
B2BKing introduces a subaccounts system integrated with permissions that enables and extends WooCommerce with a powerful multiple-buyers-per-account integration.
A subaccount is an individual account with its own username and password, connected to the main company account. The main account admin can create, edit, and delete subaccounts. A subaccount has permissions, including: permission to buy, permission to view orders, offers, purchase lists, conversations, and more. It is also possible to enable company order approval, so that subaccounts can place orders, but those orders require approval from the main account before going through.
B2BKing adds a "Subaccounts" section to the user's My Account area in WooCommerce. Here, subaccounts can be added, edited, and deleted.
You can easily view and organize accounts and subaccounts through B2BKing's dedicated "Customers" section. Here you can search for users by company name, account type, or customer group.
To create a subaccount, you must enter login details (username, email, password), provide the personal details of the account user, and set the permissions for the subaccount.
By default, this area will show configurable Email and Password fields.
You can remove the password area to let subaccounts choose their own password by adding this code snippet:
add_filter('b2bking_subaccounts_set_own_password','__return_true');
You can also add the Username as a configurable field by adding this code snippet:
add_filter('b2bking_show_username_subaccounts','__return_true');
Subaccounts can access the catalog and view the same products, prices, offers, lists, etc., as the main company account, provided they have permission to access each respective area.
B2BKing adds a "Placed by" column in Orders to show who placed each individual order within an account. B2BKing also allows full control over whether subaccounts have permission to view other account orders.
Another example of this implementation is in conversations. Multiple users can participate in each conversation, and the author of each message is displayed alongside it.
An account owner can choose for each subaccount what permissions and level of access the subaccount should have. Permissions include:
The subaccounts functionality can be enabled or disabled through a dedicated setting in B2BKing's settings panel.
It is possible to set existing users as subaccounts by using the tools in B2BKing -> Tools -> User Editor:
There you can find two separate tools:
Set users as subaccounts of an account:
This tool accepts the user IDs of parent and subaccounts and connects the two when you click the button.
Turn subaccounts into regular accounts:
This tool likewise accepts user IDs and removes the subaccount status, turning them into regular user accounts.
By default, there are only 2 levels of subaccounts, meaning that a company account can create subaccounts, but subaccounts cannot create their own (further) subaccounts.
It is possible to enable a 3rd level of subaccounts by adding this PHP code snippet to your site:
add_filter('b2bking_allow_multiple_subaccount_levels','__return_true');
The subaccounts that B2BKing introduces are regular WordPress / WooCommerce accounts, with the relationships between accounts and account permissions defined through user metadata (stored in the WordPress wp_usermeta table).
Therefore, subaccount relationships can be fully managed through user metadata, which can be done via the WP or WooCommerce API.
The UI is simply a tool that controls this metadata. It can be completely removed, as long as you set or edit the metadata in a different way.
------------
Here are all the relevant meta keys and values that determine relationships and subaccount permissions:
A) Meta Keys:
Each subaccount needs the following 2 meta keys:
Each parent account must have the following meta key:
Permissions are set for each subaccount through these keys:
These keys can have a value of 0 (disabled) or 1 (enabled).
B) Functions:
You can use the following function to turn an account into the subaccount of another:
/* This snippet connects 2 accounts in B2BKing, making one account the subaccount of another. $parent_account_id should be the main account ID $subaccount_account_id needs to be set to the desired subaccount ID */ function b2bking_connect_subaccount($parent_account_id, $subaccount_account_id){ update_user_meta($subaccount_account_id,'b2bking_account_type', 'subaccount'); update_user_meta($subaccount_account_id,'b2bking_account_parent', $parent_account_id); $current_subaccounts_list = get_user_meta($parent_account_id,'b2bking_subaccounts_list', true); update_user_meta($parent_account_id,'b2bking_subaccounts_list', $current_subaccounts_list.','.$subaccount_account_id); // the following code sets subaccount permissions (1 = enabled 0 = not enabled) // enable all permissions for subaccount update_user_meta($subaccount_account_id, 'b2bking_account_permission_buy', 1); update_user_meta($subaccount_account_id, 'b2bking_account_permission_view_orders', 1); update_user_meta($subaccount_account_id, 'b2bking_account_permission_view_offers', 1); update_user_meta($subaccount_account_id, 'b2bking_account_permission_view_conversations', 1); update_user_meta($subaccount_account_id, 'b2bking_account_permission_view_lists', 1); }
Usage example:
b2bking_connect_subaccount(12, 456); // in this example 456 is the subaccount ID, and 12 is the main account ID
Powered by BetterDocs