Shop account handlers
This page is for developers who need the checkout to ask for different customer data: a company name, a VAT number, a separate delivery address, a phone number. The shop account handler decides which form the customer fills in and how the order's customer data is read back. The shipped handlers are described in shopaccount.ini walkthrough.
Contents
The five methods
The shipped handlers in kernel/classes/shopaccounthandlers/ all implement:
| Method | Called | Returns |
|---|---|---|
verifyAccountInformation() | On Checkout in the basket | true if checkout can go on without a form |
fetchAccountInformation( &$module ) | When verification failed | Redirects to the form (or to sign in) |
email( $order ) | Order mail, order list, customer list | The customer's e-mail address |
accountName( $order ) | Order list, customer list | The customer's name |
accountInformation( $order ) | Order view, receipt, mail templates | An array of the customer's data |
eZShopAccountHandler::instance() (kernel/classes/ezshopaccounthandler.php) loads the handler named in
[AccountSettings] Handler, as class <name>ShopAccountHandler, falling back to eZDefaultShopAccountHandler.
Where the data lives
The ezuser, ezsimple and bcusauser handlers keep the form's data in the order itself, as XML in
ezorder.data_text_1, and parse it back in email(), accountName() and accountInformation(). Keeping the data in
the order means it stays as entered even if the customer's account changes later. bcusauser shows how to add fields
on top of an existing handler with almost no code: it extends eZUserShopAccountHandler.
Writing one
- Copy the form view you start from:
shop/userregistercreates the temporary order and stores the XML (kernel/private/classes/views/shop/userregister.php). Put your own view in your extension's module, with the extra fields, validation and the same order creation. - Write the handler:
fetchAccountInformation()redirects to your view;email(),accountName()andaccountInformation()read your XML, including the new fields. - Templates: the order view and receipts include an account template per handler from
design/standard/templates/shop/accounthandlers/(html/andascii/); add yours in your design. - If VAT depends on the country, give the form a country field and keep it where
eZVATManagerfinds it (Product categories and VAT rules).
Protect the form like any form (Forms, CSRF and HTTP input) and keep only the data you need (GDPR requests).
Registering it
# extension/mystore_shop/settings/shopaccount.ini.append.php
[HandlerSettings]
ExtensionRepositories[]=mystore_shop
[AccountSettings]
Handler=mystorewith the class in extension/mystore_shop/shopaccounthandlers/mystoreshopaccounthandler.php. The ezauthorize
extension ships an example of this layout (shopaccounthandlers/ezcustomshopaccounthandler.php).
Checklist
- To do: Guest and signed-in checkout both reach the confirmation page.
- To do: Every new field appears in the order view, receipt, order mail and customer list.
- To do: Old orders made with the previous handler still display.
- To do: Invalid input is refused with a clear, accessible message (Store accessibility).
Related pages
- Extending the shop
- Customer accounts and guest checkout
- Customer accounts (running your store)
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.