Hello, I need to allow my client to view all orders on the site while preventing them from causing "damage" by accessing settings for WooCommerce, B2BKing, etc. Essentially, I would like to create an account that can view *only* the orders. Is this possible? I have B2BKing and SalesKing installed. Could you provide a guide? Thanks.
Account Rule
Hi Paul,
Thanks for reaching out. I think you have two main options here:
Option 1 - Set the client up as a SalesKing agent
Agent accounts are naturally restricted, so they shouldn't have access to settings. Agents can view orders either in the WordPress backend, or directly in the frontend agent dashboard page if you enable SalesKing -> Settings -> Agent Capabilities -> Frontend Order Management.
By default agents see the orders of the customers assigned to them, but we could write a code snippet so that a specific agent sees all orders.
This is probably the simplest / built-in way. I'd recommend giving it a try to see exactly what is possible and what's not, some order editing features are restricted, so I'm not completely sure if that will be enough for your needs.
Option 2 - Create a custom WordPress role
You can use a free plugin such as User Role Editor or Members to create a new role (e.g. "Order Viewer") and give it only the order-related capabilities (read, edit_shop_orders, read_shop_orders, etc.), while leaving out capabilities like manage_woocommerce and manage_options.
Let me know your thoughts,
Kind regards,
Stefan
Yes, I think Option 1 works well;
it isn't essential to be able to edit the orders, but it is important to be able to view them and see any notes attached to the order.
Is it possible to insert this code snippet into the child theme's functions.php file?
If a name needs to be assigned beforehand, I would call this specific user "Ordini".
Thanks
Hi Paul,
Thanks for getting back to me,
Yes, you can add the snippet to your child theme's functions.php, or any code snippets plugin.
I recommend these steps:
1. Create the "Ordini" user account and set it up as a SalesKing sales agent (https://prnt.sc/seCLPN8Z1YOo). I'd keep its WordPress role as Customer rather than Shop Manager.
2. Find the account's user ID - edit the user and look at the browser address bar, where you'll see something like ?user_id=123.
3. Add this snippet, replacing 123 with that ID:
add_filter( 'salesking_agents_see_all_orders', function( $see_all ) {
if ( 123 === (int) get_current_user_id() ) {
return true;
}return $see_all;
}, 10, 1 );
4. Go to SalesKing > Settings > Agent Capabilities and enable Manage Assigned Orders and Frontend Order Management.
After that, the Ordini user should see all orders in the frontend agent dashboard and can open any order to view its notes. Other agents will still only see their own assigned orders.
Let me know if you run into any issues with it or if you have any questions!
Kind regards,
Stefan
Thank you for the reply.
I followed the instructions carefully, but unfortunately, it isn't working.
I can correctly see the page dedicated to the agent and all its options, but the page throws an error specifically when I click on "orders".
Hi Paul,
Thanks for the update,
I double-checked the snippet and also tested it on my end, but it seems to work fine in my tests.
I think the error is likely caused by the number of orders on the site. If you have many orders, the page tries to load all of them at once, which can make it crash.
Please go to SalesKing > Settings > Performance, enable Load Orders with AJAX, and save the settings. It's the setting shown here: https://prnt.sc/FtyZfs_YhjkK
(if you do not see that setting, please make sure to update SalesKing to the latest version).
If that setting doesn't solve it, would you be able to share a backend login to the site, or a staging clone site? Then I can check this directly.
Kind Regards,
Stefan
Hi Paul,
Thanks for getting back to me,
The Performance tab was added quite recently and doesn't exist in 1.8.20. Please update to the latest 1.8.60 version (https://b2bkingplugin.com/docs/salesking-changelog/), and you should see that setting in SalesKing > Settings > Performance -> Load Orders with AJAX.
If you'd prefer to stay on your current version for now, you can also enable AJAX loading by adding this line to your child theme's functions.php or any code snippets plugin:
add_filter( 'salesking_load_orders_table_ajax', '__return_true' );
There's no built-in setting to show only the last 3-6 months or the last 100 orders, but we could also do that with a code snippet if needed. That said, I think the AJAX option is the better fix. It loads orders in batches, one page at a time,
Let me know if that works for you,
Kind Regards,
Stefan