User Type Switcher: Setup Guide
This guide is intended for developers setting up the Venta User Type Switcher module in a Magento project.
It assumes the module has been installed via Composer and that you are working with Venta Theme on top of Hyva Theme, including Hyvä Checkout.
Prerequisites
Required
- Magento: 2.4.x
- PHP: 8.1 or higher
- Themes and modules:
- Hyva Theme
- Venta Theme
- Hyvä Checkout (
hyva-themes/magento2-hyva-checkout) Magebit_VentaUserTypeSwitcherenabled
- Core Magento modules (normally present on any standard store):
Magento_CustomerMagento_QuoteMagento_SalesMagento_TaxMagento_CheckoutMagento_Backend
High-Level Setup Flow
- Verify module installation and status.
- Enable the module and run
setup:upgrade. - Enable the store-config flag under
Stores → Configuration → Magebit → User Type Switcher. - Configure tax for legal customers under
Stores → Configuration → Sales → Tax → Calculation Settings. - Verify frontend behaviour on the Hyvä checkout and in My Account.
Step 1: Verify Installation & Module Status
- Confirm that the Composer package has been installed in your Magento project:
d/composer require magebitcom/magento2-venta-theme-user-type-switcher- From inside your Docker container / project root, run:
d/magento module:status Magebit_VentaUserTypeSwitcherStep 2: Enable the Module
- If the module is disabled, enable it and apply the schema and data changes:
d/magento module:enable Magebit_VentaUserTypeSwitcher
d/magento setup:upgradesetup:upgrade applies etc/db_schema.xml (which adds the user_type and reference columns to quote_address, sales_order_address and customer_address_entity) and runs Setup/Patch/Data/AddAddressAttributes (which registers user_type and reference as customer_address EAV attributes).
- Clear caches:
d/magento cache:flushStep 3: Enable User Type Switcher in Admin
The module is disabled by default and stays fully inert until a store enables it. While off it renders no UI or scripts and makes no address or tax changes. Turn it on to activate the switcher.
- Navigate to:
Stores → Configuration → Magebit → User Type Switcher
- Under General:
- Enable User Type Switcher (
magebit_user_type_switcher/general/enabled)- Set to Yes to show the Private / Business switcher in checkout and My Account and apply its behaviour.
- Default No.
This section supports the standard default / website / store-view configuration scopes.
- Save the configuration and flush cache if needed:
d/magento cache:flushStep 4: Configure Tax for Legal Customers
Tax behaviour for business customers is controlled by a dedicated field, independent of the enable flag.
- Navigate to:
Stores → Configuration → Sales → Tax → Calculation Settings
- Set Apply Taxes To Legal Customers (
tax/calculation/apply_legal_person_tax):
- No (default): tax is removed for VAT-registered legal persons (B2B). Tax is only removed when the customer is Business and a VAT ID is present on the billing or shipping address.
- Yes: keep charging tax for business customers.
This applies at both storefront checkout and admin order creation.
Step 5: Verify Frontend Behaviour
Use a test scenario to validate the end-to-end flow:
- Checkout (billing & shipping): A two-button Private / Business toggle appears on both the billing and shipping address forms. Selecting Business reveals the Company, VAT Number and Registration Number fields (Company and VAT Number required); Private shows no extra fields. Each form tracks its own toggle.
- Checkout (persistence): Place an order as a Business customer and confirm the type, company, VAT number and registration number persist onto the quote and the resulting order address. Switching to Private clears the business fields; using "same as billing" mirrors the user-type fields onto the billing address.
- My Account (address form): The same Private / Business toggle appears on the address edit form. The saved type is pre-selected when editing an existing address (defaulting to Private for a new one), and selecting Business reveals the same fields.
- My Account (VAT check): Entering a malformed VAT number for a recognised country prefix (e.g. LV, LT, EE, DE, FR, NL) shows an advisory, non-blocking warning; unrecognised prefixes are not flagged.
- Tax: With Apply Taxes To Legal Customers set to No, confirm tax is removed for a Business customer that has a VAT ID.
For a full UX walkthrough, refer to the main User Type Switcher extension page.
Troubleshooting & Tips
The Switcher Does Not Appear
- Confirm the module is enabled at
Stores → Configuration → Magebit → User Type Switcher → Enable User Type Switcher
(magebit_user_type_switcher/general/enabled). It defaults to No and the module is fully inert while off. - Ensure the module is installed and active:
d/magento module:status Magebit_VentaUserTypeSwitcher- Verify the theme in use is Venta Theme (or a child) on top of Hyva, with Hyvä Checkout installed.
- Clear caches and re-deploy static content if templates or configuration were recently changed.
Tax Is Not Removed for Business Customers
- Confirm Apply Taxes To Legal Customers is set to No at
Stores → Configuration → Sales → Tax → Calculation Settings
(tax/calculation/apply_legal_person_tax). - Tax is only removed when the customer is Business and a VAT ID is present on the billing or shipping address. Check both were captured.
- Confirm the module is enabled for the relevant store scope.
Business Fields Are Missing After Save
- The business fields (
company,vat_id,reference) are intentionally cleared when the user type is Private. Confirm the saved type is Business. - On the customer address save, the clearing only runs when the submitted
user_typerequest param is present; a save from an unrelated flow will not carry it. - Verify the address save is going through the Hyvä billing/shipping save service (checkout) or
AddressRepositoryInterface(My Account) so the module's plugins run.
Schema or Attributes Missing
- Ensure database migrations and data patches have run successfully:
d/magento setup:upgrade