Skip to content

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_VentaUserTypeSwitcher enabled
  • Core Magento modules (normally present on any standard store):
    • Magento_Customer
    • Magento_Quote
    • Magento_Sales
    • Magento_Tax
    • Magento_Checkout
    • Magento_Backend

High-Level Setup Flow

  1. Verify module installation and status.
  2. Enable the module and run setup:upgrade.
  3. Enable the store-config flag under
    Stores → Configuration → Magebit → User Type Switcher.
  4. Configure tax for legal customers under
    Stores → Configuration → Sales → Tax → Calculation Settings.
  5. Verify frontend behaviour on the Hyvä checkout and in My Account.

Step 1: Verify Installation & Module Status

  1. Confirm that the Composer package has been installed in your Magento project:
bash
d/composer require magebitcom/magento2-venta-theme-user-type-switcher
  1. From inside your Docker container / project root, run:
bash
d/magento module:status Magebit_VentaUserTypeSwitcher

Step 2: Enable the Module

  1. If the module is disabled, enable it and apply the schema and data changes:
bash
d/magento module:enable Magebit_VentaUserTypeSwitcher
d/magento setup:upgrade

setup: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).

  1. Clear caches:
bash
d/magento cache:flush

Step 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.

  1. Navigate to:

Stores → Configuration → Magebit → User Type Switcher

  1. 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.

  1. Save the configuration and flush cache if needed:
bash
d/magento cache:flush

Tax behaviour for business customers is controlled by a dedicated field, independent of the enable flag.

  1. Navigate to:

Stores → Configuration → Sales → Tax → Calculation Settings

  1. 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:
bash
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_type request 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:
bash
d/magento setup:upgrade