With commercebuild for WooCommerce, shortcodes make it easy to show customer information or even switch between customers linked to a user account. This is especially useful for B2B ecommerce, where a single login might have access to multiple customer records.
Using Shortcodes to Display and Switch Customers in WooCommerce
In WordPress, a shortcode is a simple text snippet placed inside square brackets, like [example_shortcode]
that tells your site to run a specific function without you touching any code. Think of it as a quick command that magically drops a feature or piece of content right where you want it.
In this case, there are two shortcodes you can use: one to display the current customer code/number, and another to give users the option to switch between customers.
Current Customer Number
[cfw_current_customer_number]
This shortcode will display the first and last name of the user logged in, as well as the current customer number/code to which they are linked.
A/R Customer Switcher
[cfw_arcust_switching]
This short will display a link that allows a user to switch customers that are associated with their user. In some cases, this can be all customers in the ERP or a predefined list.
Upon clicking the Switch A/R Customer link, a popup will appear that will allow you to search all customer numbers/codes associated with your user and select the desired one from the list.