Buy B2BKing
$199 $149
B2BKing introduces Subaccounts as a way of providing 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 to have multiple employees that have access to an account, to see prices, place orders, communicate with the rest of the team, etc.
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, etc. It is also possible to enable company order approval, so that subaccounts can place orders, but these orders require approval from the main account before going through.
B2BKing adds a "Subaccounts" section to users' 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), personal details of the account user, and set what permissions the subaccount has.
Whether or not the username and password are available here as fields, depends on your settings in WooCommerce -> Settings -> Accounts & Privacy -> Account creation. View settings.
Subaccounts can access the catalog and view the same products, prices, offers, lists, etc as the main company account, if they have permission to access each respective area.
B2BKing adds a "Placed by" column in Orders, to show who placed any individual order within an account. B2BKing also allows full control over whether subaccounts have permissions to view other account orders.
Another example of this implementation is in conversations. Multiple users can participate in each conversation, and the message's author is attached to each message.
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 2 separate tools:
Set users as subaccounts of account:
This tool accepts the user IDs of parent and sub-accounts, and connects the 2 when clicking the button.
Turn subaccounts into regular accounts:
This tool likewise accepts user IDs, and removes the subaccount status of the accounts, making them normal 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 B2BKing introduces are regular WordPress / WooCommerce accounts, with the relationships between accounts and account permissions defined through user meta data (defined in the WordPress wp_usermeta table ).
Therefore subaccount relationships can be fully managed through user meta data, which can be done through the WP or the WooCommerce API.
-> The UI is just a tool that controls this metadata. It can be completely removed, as long as you set / edit the meta data in a different way.
------------
Here are all the relevant meta keys and values which 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 the 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