public function onToggleEmployeeSubscriptionFields(array &$allowed, array $billing, object $employee) : void

Fires before displaying the billing form to purchase an employee subscription.


Description

Trigger hook to toggle the visibility of certain fields from the Subscriptions page under the Employees Area.

In example, by using the code below, the user profile won't display the VAT Number field anymore.

$allowed['vat'] = false;
// or
unset($allowed['vat']);

Parameters

&$allowed

(array)  An associative array containing all the allowed fields, where the key is the field identifier and the value represents its visibility.

  • country - the dropdown to pick the country;
  • state - the text field to enter the state/province;
  • city - the text field to enter the city name;
  • address - the text field to enter the address field;
  • zip - the text field to enter the ZIP code;
  • company - the text field to enter the company name;
  • vat - the text field to enter the VAT number.

Assigning new attributes to the array will have no effect.

$billing

(array)  An array holding the currently set billing details.

$employee

(object)  The details of the currently logged-in employee.

Return Value

None.


Example

The following example hides the Company and VAT Number fields only if they are empty.

/**
 *  Trigger hook to toggle the visibility of certain fields.
 *
 * @param   array   &$allowed  An array of allowed fields.
 * @param   array   $billing   An associative array containing the
 *                             value of the billing fields.
 * @param   object  $employee  The employee details.
 *
 * @return  void
 */
public function onToggleEmployeeSubscriptionFields(&$allowed, $billing, $employee)
{
    // check whether the Company field is empty
    if (empty($billing['company']))
    {
        // hide field
        $allowed['company'] = false;
    }

    // check whether the VAT Number field is empty
    if (empty($billing['vat']))
    {
        // hide field
        $allowed['vat'] = false;
    }
}

Changelog

VersionDescription
1.7 Introduced.
Last Update: 2021-10-08 09:26
Helpful?
This site uses cookies. By continuing to browse you accept their use. Further information