Difference between revisions of "Provisioning Modules and Addons Developer Migration Guide"
(Created page with "WHMCS 7.2 introduces the ability to associate Product Add-ons with Provisioning Modules. For many provisioning modules, this won't require any changes at all. For some modul...") |
|||
Line 1: | Line 1: | ||
− | WHMCS 7.2 | + | In WHMCS 7.2 and later, you can associate [[Product Addons|product addons]] with provisioning modules. |
− | + | This may require small changes to modules for which any of the following statements are true: | |
− | + | * It performs database updates to the <tt>tblhosting</tt> table, which stores service information. | |
+ | * It uses custom database tables or tracks relationships based on the service ID. | ||
+ | * It uses custom fields. | ||
− | == | + | ==Database Changes== |
− | + | Prior to WHMCS 7.2, whenever you invoked a module action, it was for a product or service in the <tt>tblhosting</tt> database table and you would always receive a <tt>serviceid</tt> value. In WHMCS 7.2 and later, module actions may also be for addons and you may receive an <tt>addonId</tt> value that contains the addon's ID (<tt>tblhostingaddons.id</tt>). | |
− | + | There are two ways to determine whether the module action will act on an addon or a product or service: | |
− | |||
− | |||
− | + | # Check for the existence of an <tt>addonId</tt> value. If one is defined, the module action is acting on a product addon. | |
− | + | # Assert the type of the provided model:<source lang="php"> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | # | ||
− | # | ||
− | |||
− | <source lang="php"> | ||
if ($params['model'] instanceof \WHMCS\Service\Service) { | if ($params['model'] instanceof \WHMCS\Service\Service) { | ||
// Method was invoked for a Service | // Method was invoked for a Service | ||
Line 34: | Line 22: | ||
</source> | </source> | ||
− | + | ==Custom Fields== | |
− | |||
− | |||
− | + | In WHMCS 7.2, we also introduced support for [[Custom Fields|custom fields]] for product addons. This allows you to store additional product-related information that many provisioning modules require. | |
− | A Service Property is a key/value pair | + | To make it easier to work with these custom fields, WHMCS 7.2 also introduced [[Service Properties]]. A Service Property is a key/value pair in a custom field that relates to an instance of a product or addon. Service Properties allow module developers to interact with custom fields in a simple programmatic way that is consistent for both products and addons. |
− | If you store any values | + | If you store any values in custom fields as part of your module code, relating it to the <tt>serviceid</tt> value for which the action is being performed, see [[Service Properties]] for information about additional changes you may need to make. |
Latest revision as of 21:01, 28 April 2022
In WHMCS 7.2 and later, you can associate product addons with provisioning modules.
This may require small changes to modules for which any of the following statements are true:
- It performs database updates to the tblhosting table, which stores service information.
- It uses custom database tables or tracks relationships based on the service ID.
- It uses custom fields.
Database Changes
Prior to WHMCS 7.2, whenever you invoked a module action, it was for a product or service in the tblhosting database table and you would always receive a serviceid value. In WHMCS 7.2 and later, module actions may also be for addons and you may receive an addonId value that contains the addon's ID (tblhostingaddons.id).
There are two ways to determine whether the module action will act on an addon or a product or service:
- Check for the existence of an addonId value. If one is defined, the module action is acting on a product addon.
- Assert the type of the provided model:
if ($params['model'] instanceof \WHMCS\Service\Service) { // Method was invoked for a Service } elseif ($params['model'] instanceof \WHMCS\Service\Addon) { // Method was invoked for an Add-on }
Custom Fields
In WHMCS 7.2, we also introduced support for custom fields for product addons. This allows you to store additional product-related information that many provisioning modules require.
To make it easier to work with these custom fields, WHMCS 7.2 also introduced Service Properties. A Service Property is a key/value pair in a custom field that relates to an instance of a product or addon. Service Properties allow module developers to interact with custom fields in a simple programmatic way that is consistent for both products and addons.
If you store any values in custom fields as part of your module code, relating it to the serviceid value for which the action is being performed, see Service Properties for information about additional changes you may need to make.