Developer notes
Overview · Installation · Configuration · Usage · FAQ
Data model
Section titled “Data model”| Table | Content |
|---|---|
?:kv_b2breg_applications |
One row per application: storefront (company_id, Ultimate), user_id, status (P pending, I information requested, A approved, D declined), company data, VAT number with vat_country, vat_status (N not checked, V valid, I invalid, U unavailable, X not an EU number), VIES name/address, custom answers and meta data (extra, JSON), assigned usergroup_ids, reason (decline reason, request text or approval message), timestamps |
?:kv_b2breg_documents |
Uploaded files: application, custom field (0 = documents section), type, original name, storage path, size |
?:kv_b2breg_log |
History: action, status after it, message, author |
?:kv_b2breg_fields, ?:kv_b2breg_field_descriptions |
Custom fields (type T/A/S/C/F, required, position, status) with label, options and help per language |
Approval uses the core fn_change_usergroup_status('A', ...) (revoke: 'D'); the tax exemption is the core users.tax_exempt flag.
Controllers and endpoints
Section titled “Controllers and endpoints”| Dispatch | Area | Purpose |
|---|---|---|
kv_b2b_registration.apply |
Storefront | GET form, POST submit (multipart; core anti-bot scenario register) |
kv_b2b_registration.status |
Storefront | Trade account page; POST kv_b2b_registration.update answers an information request |
kv_b2b_registration.check_vat |
Storefront | AJAX POST live VIES check (10 checks per session and hour, answers cached for 15 minutes) |
kv_b2b_registration.manage, .update, .fields, .field |
Admin | Queue, application page, custom fields |
kv_b2b_registration.approve, .decline, .request_info, .note, .recheck_vat, .delete_document, .delete, .m_delete, .field_update, .field_delete, .cleanup |
Admin (POST) | Actions; privileges view_kv_b2b_registration (GET) and manage_kv_b2b_registration (POST) |
kv_b2b_registration.download |
Admin | Document download after a scope check |
php admin.php --dispatch=kv_b2b_registration.cleanup |
Console | Privacy cleanup |
The vendor panel has no access (vendor_multivendor permissions schema).
Core hooks used: post_delete_user (removes the customer’s applications and files) and before_dispatch (hourly privacy cleanup on admin GET pages). Both have the same arguments in 4.17.2 and 4.21.2.
Hooks for your own code:
| Hook | Arguments |
|---|---|
kv_b2b_registration_submitted |
$application_id, $row |
kv_b2b_registration_approved |
$application_id, $user_id, $assigned_usergroup_ids |
kv_b2b_registration_declined |
$application_id, $user_id, $revoked |
kv_b2b_registration_notify_pre |
$event, &$data, &$rules (change e-mail data or receivers) |
Notification events: kv_b2b_registration.submitted, .updated, .approved, .declined, .info_requested (group kv_b2b_registration).
VIES client
Section titled “VIES client”Tygh\Addons\KvB2bRegistration\Vies calls the public REST service https://ec.europa.eu/taxation_customs/vies/rest-api/ms/{CC}/vat/{number} with the core HTTP client and the configured timeout. Only isValid: true counts as valid and only isValid: false with userError: INVALID as invalid; every other answer, HTTP error or timeout is “unavailable”. For tests, define('KV_B2BREG_VIES_URL', 'http://127.0.0.1:<port>') in local_conf.php points the client at a local mock (only localhost / 127.0.0.1 URLs are accepted).
Full page cache (4.21)
Section titled “Full page cache (4.21)”The links (registration page, account menu) and the call-to-action block depend only on the settings and the license, so cached pages are the same for every visitor; the account menu is rendered by core as a session-dependent block. The application pages are not cacheable dispatches, and every change is a POST. Nothing is written on storefront GET requests; the cleanup run mark is written only from the admin area, into var/kv_storage while the full page cache is on.
License check
Section titled “License check”Tygh\Addons\KvB2bRegistration\License\Client (generated) verifies the license. Gate points: Config::isActive() (form page, submit, live VAT check, links, call-to-action block). Not gated: the Trade account page of an existing application, the admin queue, decisions and document downloads, so started applications can always be finished.
Not in 1.0.0
Section titled “Not in 1.0.0”Vendor-level trade accounts on Multi-Vendor, a REST API entity, automatic approval rules, credit limits and payment terms per customer, custom fields per storefront on Ultimate.
File map
Section titled “File map”| Path | Purpose |
|---|---|
app/addons/kv_b2b_registration/addon.xml |
Settings, tables, privileges, e-mail templates |
init.php, func.php |
Hooks, settings info handlers, storefront flags, fn_kv_b2b_registration_is_licensed() |
Tygh/Addons/KvB2bRegistration/Service.php |
Validation, submit, update, approve, decline, request information, retention |
Applications.php, Fields.php, Documents.php |
Storage and search, custom fields, uploads and downloads |
Vies.php, Config.php, Notifier.php, ApplicationDataProvider.php, StorageData.php |
VIES client, settings, notifications, run marks |
License/, controllers/backend/kv_b2b_registration_license.php |
License check (generated) |
Upgrade/Synchronizer.php |
Self-healing upgrades (generated) |
controllers/frontend/, controllers/backend/ |
Pages and endpoints |
schemas/ |
Menu, permissions, anti-bot rule, block, notification events, settings variants |
var/themes_repository/responsive/templates/addons/kv_b2b_registration/ |
Form, status page, block and hook templates |
js/addons/kv_b2b_registration/func.js |
Document rows and live VAT check (jQuery) |