Provisioning Modules and Addons Developer Migration Guide
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.