Difference between revisions of "Additional Domain Fields"
(→What are additional domain fields?) |
|||
(11 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
− | <div class="docs-alert-info"><i class="fa fa- | + | <div class="docs-alert-info"><i class="fa fa-info-circle"></i> This page describes a feature available in version 7.0 and above.</div> |
==What are additional domain fields?== | ==What are additional domain fields?== | ||
− | Additional domain fields ( | + | Additional domain fields (or Extended Attributes) define the information that domain registries require for a given TLD. |
− | When a domain registry requires | + | When a domain registry requires information, a domain name will fail to register successfully unless you provide the values. For example, the information that domain registries request often includes things like the Registrant Legal Type and Registered Entity Name. |
− | + | For general information about domains in WHMCS, see [[Domains Management]]. | |
==When are the fields asked for?== | ==When are the fields asked for?== | ||
− | Domain fields | + | Domain fields display in the shopping cart during the '''Domains Configuration''' step of the order process. If the system requires a field, customers must provide the requested information before moving to the next step. |
− | + | The system saves the values in these fields and submits them to the domain's registrar. | |
− | + | ==How do I customise the displayed fields?== | |
− | + | You can find the default field definitions that we ship with WHMCS in <tt>/resources/domains/dist.additionalfields.php</tt>. | |
− | == | + | <div class="docs-alert-danger"> |
+ | <span class="title">Warning</span><br /> | ||
+ | * Do '''not''' edit this file. | ||
+ | * Prior to WHMCS 7.0, this file existed at <tt>/includes/additionaldomainfields.php</tt>. | ||
+ | </div> | ||
− | + | To customise the fields, create a new <tt>additionalfields.php</tt> file within the <tt>/resources/domains/</tt> directory. | |
− | + | ====Add a new field==== | |
− | To | + | To add a new field, create a new entry in your custom <tt>/resources/domains/additionalfields.php</tt> file. Use the field formatting in the <tt>/resources/domains/dist.additionalfields.php</tt> file as a reference: |
− | + | <div class="source-cli"> | |
+ | $additionaldomainfields[".co.uk"][] = array( | ||
+ | <br/> "Name" => "Date of Birth", | ||
+ | <br/> "Type" => "text", | ||
+ | <br/> "Size" => "30", | ||
+ | <br/>); | ||
+ | </div> | ||
+ | |||
+ | ====Edit an existing field==== | ||
+ | |||
+ | To edit an existing field: | ||
− | # | + | # Copy and paste the field definition from the <tt>/resources/domains/dist.additionalfields.php</tt> file into your custom <tt>/resources/domains/additionalfields.php</tt> file. |
− | # | + | # Remove any key-and-value pairs for parameters you do not wish to customize. |
+ | # Customize the remaining options. To define a Display Name, add the pipe (<tt>|</tt>) symbol with the desired display name (for example, <tt>1|Individual</tt>). | ||
− | < | + | <div class="source-cli"> |
$additionaldomainfields[".co.uk"][] = array( | $additionaldomainfields[".co.uk"][] = array( | ||
− | + | <br/> "Name" => "Legal Type", | |
− | + | <br/> "Options" => "1|Individual,2|UK Limited Company,3|UK Public Limited Company", | |
− | + | <br/>); | |
− | ); | + | </div> |
− | </ | ||
− | + | ====Remove a field==== | |
− | + | To remove an existing field, define the field within your custom <tt>/resources/domains/additionalfields.php</tt> file and set the '''Remove''' attribute to <tt>true</tt>. | |
− | |||
− | |||
− | < | + | <div class="source-cli"> |
$additionaldomainfields[".co.uk"][] = array( | $additionaldomainfields[".co.uk"][] = array( | ||
− | + | <br/> "Name" => "Company ID Number", | |
− | + | <br/> "Remove" => true, | |
− | ); | + | <br/>); |
− | </ | + | </div> |
+ | |||
+ | ====Translate a field name==== | ||
− | + | To translate a field name: | |
− | # Define the field within your custom | + | # Define the field within your custom <tt>/resources/domains/additionalfields.php</tt> file and set the '''LangVar''' attribute to the desired language variable. |
+ | # Add the translation string with the corresponding attribute to your language override file. | ||
− | < | + | <div class="source-cli"> |
$additionaldomainfields[".co.uk"][] = array( | $additionaldomainfields[".co.uk"][] = array( | ||
− | + | <br/> "Name" => "Legal Type", | |
− | + | <br/> "Options" => "Individual,UK Limited Company,UK Public Limited Company", | |
− | ); | + | <br/> "LangVar" => "uktldlegaltype", |
− | </source> | + | <br/>); |
+ | </div> | ||
+ | |||
+ | Language override file entry: | ||
+ | |||
+ | <div class="source-cli"> | ||
+ | $_LANG['uktldlegaltype'] = "Custom Field Label Text"; | ||
+ | </div> | ||
+ | |||
+ | You can translate the field name via [https://developers.whmcs.com/languages/overrides/ language override files]. This allows you to change the label on the shopping cart next to the additional domain field based upon the language in which the visitor is viewing your site. For more information, see [[Easy_Translation#Localising_a_Field|Easy Translation]]. | ||
==Prepopulated Data Variables== | ==Prepopulated Data Variables== | ||
Line 68: | Line 92: | ||
The following variables are available for use with dropdown field types. | The following variables are available for use with dropdown field types. | ||
− | <table class="table table-striped"> | + | <table class="table table-striped table-condensed"> |
− | <tr>< | + | <tr><th>Tag</th><th>Description</th></tr> |
− | <tr><td>{Countries}</td><td>Provides a comma separated list of countries. | + | <tr><td><tt>{Countries}</tt></td><td>Provides a comma-separated list of countries. The system will save a full country name and pass it to the registrar for the field (for example, United Kingdom).</td></tr> |
− | <tr><td>{CountryCodeMap}</td><td>Provides an associative key value pair list of country codes and country names. This will display the full country name for a user to | + | <tr><td><tt>{CountryCodeMap}</tt></td><td>Provides an associative key-and-value pair list of country codes and country names. This will display the full country name for a user to choose, but it will only store and pass the ISO country code to the registrar (for example, GB).</td></tr> |
</table> | </table> | ||
− | + | For example: | |
− | < | + | <div class="source-cli"> |
$additionaldomainfields[".co.uk"][] = array( | $additionaldomainfields[".co.uk"][] = array( | ||
− | + | <br/> "Name" => "Registered Country", | |
− | + | <br/> "Type" => "dropdown", | |
− | + | <br/> "Options" => "{Countries}", | |
− | ); | + | <br/>); |
− | </source> | + | </div> |
+ | |||
+ | ==Conditional Requirements== | ||
+ | |||
+ | <div class="docs-alert-info"><i class="fa fa-info-circle"></i>This feature is available in WHMCS 7.9 and above.</div> | ||
+ | |||
+ | You can set additional domain fields as never required, always required, or conditionally required. A conditional requirement allows you to denote a field as required only when another field contains a certain value. This allows you to define more complex validation rules. | ||
+ | |||
+ | ===How it Works=== | ||
+ | |||
+ | Consider the following example of defining a conditionally-required additional domain field: | ||
+ | |||
+ | <div class="source-cli"> | ||
+ | $additionaldomainfields['.co.uk'][] = [ | ||
+ | <br/> 'Name' => 'Company ID Number', | ||
+ | <br/> 'LangVar' => 'uktldcompanyid', | ||
+ | <br/> 'Type' => 'text', | ||
+ | <br/> 'Size' => '30', | ||
+ | <br/> 'Required' => [ | ||
+ | <br/> 'Legal Type' => [ | ||
+ | <br/> 'UK Limited Company', | ||
+ | <br/> 'UK Public Limited Company', | ||
+ | <br/> ], | ||
+ | <br/> ], | ||
+ | <br/>]; | ||
+ | </div> | ||
+ | |||
+ | The example above only requires the '''Company ID Number''' field when the value of the '''Legal Type''' field is either "UK Limited Company" or "UK Public Limited Company". | ||
+ | |||
+ | To define a conditional requirement, set the value of the <tt>Requires</tt> key to an array containing a list of field names and values that trigger the requirement. The array syntax here supports defining multiple fields, and the system will require the field if any of the required fields have one of the defined values. | ||
+ | |||
+ | As with all customizations, if you wish to override the default requirements for a given field, use an override file. |
Latest revision as of 16:07, 18 April 2022
Contents
What are additional domain fields?
Additional domain fields (or Extended Attributes) define the information that domain registries require for a given TLD.
When a domain registry requires information, a domain name will fail to register successfully unless you provide the values. For example, the information that domain registries request often includes things like the Registrant Legal Type and Registered Entity Name.
For general information about domains in WHMCS, see Domains Management.
When are the fields asked for?
Domain fields display in the shopping cart during the Domains Configuration step of the order process. If the system requires a field, customers must provide the requested information before moving to the next step.
The system saves the values in these fields and submits them to the domain's registrar.
How do I customise the displayed fields?
You can find the default field definitions that we ship with WHMCS in /resources/domains/dist.additionalfields.php.
Warning
- Do not edit this file.
- Prior to WHMCS 7.0, this file existed at /includes/additionaldomainfields.php.
To customise the fields, create a new additionalfields.php file within the /resources/domains/ directory.
Add a new field
To add a new field, create a new entry in your custom /resources/domains/additionalfields.php file. Use the field formatting in the /resources/domains/dist.additionalfields.php file as a reference:
$additionaldomainfields[".co.uk"][] = array(
"Name" => "Date of Birth",
"Type" => "text",
"Size" => "30",
);
Edit an existing field
To edit an existing field:
- Copy and paste the field definition from the /resources/domains/dist.additionalfields.php file into your custom /resources/domains/additionalfields.php file.
- Remove any key-and-value pairs for parameters you do not wish to customize.
- Customize the remaining options. To define a Display Name, add the pipe (|) symbol with the desired display name (for example, 1|Individual).
$additionaldomainfields[".co.uk"][] = array(
"Name" => "Legal Type",
"Options" => "1|Individual,2|UK Limited Company,3|UK Public Limited Company",
);
Remove a field
To remove an existing field, define the field within your custom /resources/domains/additionalfields.php file and set the Remove attribute to true.
$additionaldomainfields[".co.uk"][] = array(
"Name" => "Company ID Number",
"Remove" => true,
);
Translate a field name
To translate a field name:
- Define the field within your custom /resources/domains/additionalfields.php file and set the LangVar attribute to the desired language variable.
- Add the translation string with the corresponding attribute to your language override file.
$additionaldomainfields[".co.uk"][] = array(
"Name" => "Legal Type",
"Options" => "Individual,UK Limited Company,UK Public Limited Company",
"LangVar" => "uktldlegaltype",
);
Language override file entry:
$_LANG['uktldlegaltype'] = "Custom Field Label Text";
You can translate the field name via language override files. This allows you to change the label on the shopping cart next to the additional domain field based upon the language in which the visitor is viewing your site. For more information, see Easy Translation.
Prepopulated Data Variables
The following variables are available for use with dropdown field types.
Tag | Description |
---|---|
{Countries} | Provides a comma-separated list of countries. The system will save a full country name and pass it to the registrar for the field (for example, United Kingdom). |
{CountryCodeMap} | Provides an associative key-and-value pair list of country codes and country names. This will display the full country name for a user to choose, but it will only store and pass the ISO country code to the registrar (for example, GB). |
For example:
$additionaldomainfields[".co.uk"][] = array(
"Name" => "Registered Country",
"Type" => "dropdown",
"Options" => "{Countries}",
);
Conditional Requirements
You can set additional domain fields as never required, always required, or conditionally required. A conditional requirement allows you to denote a field as required only when another field contains a certain value. This allows you to define more complex validation rules.
How it Works
Consider the following example of defining a conditionally-required additional domain field:
$additionaldomainfields['.co.uk'][] = [
'Name' => 'Company ID Number',
'LangVar' => 'uktldcompanyid',
'Type' => 'text',
'Size' => '30',
'Required' => [
'Legal Type' => [
'UK Limited Company',
'UK Public Limited Company',
],
],
];
The example above only requires the Company ID Number field when the value of the Legal Type field is either "UK Limited Company" or "UK Public Limited Company".
To define a conditional requirement, set the value of the Requires key to an array containing a list of field names and values that trigger the requirement. The array syntax here supports defining multiple fields, and the system will require the field if any of the required fields have one of the defined values.
As with all customizations, if you wish to override the default requirements for a given field, use an override file.