public function onPrepareFieldsSaveSubscriptionOrder(array &$fields, array &$args) : void

Fires after fetching the custom fields set in request.


Description

Trigger hook to manipulate the custom fields array and the billing information of the customer, extrapolated through the rules of the custom fields.

In case you are using a third-party plugin to collect the details of the customer, it is possible to inject into $args array all the information that you wish to register.


Parameters

&$fields

(array)  An associative array containing the custom fields entered by the customer. The array keys match the names of the custom fields, the values match the details specified by the customer instead.

&$args

(array)  An associative array containing the billing details of the customer.

Return Value

None.


Example

Assuming that no custom fields are used, the system auto-inject the phone number of the customer into the array holding the billing details.

/**
 * Trigger event to manipulate the custom fields array and the
 * billing information of the customer, extrapolated from the rules
 * of the custom fields.
 *
 * @param   array  &$fields  The custom fields values.
 * @param   array  &$args    The billing array.
 *
 * @return  void
 */
public function onPrepareFieldsSaveSubscriptionOrder(&$fields, &$args)
{
    // get details of the current user
    $user = JFactory::getUser();

    if ($user->guest)
    {
        retur;
    }

    // assume that the phone number is contained within the details of the currently logged-in user
    if (empty($args['purchaser_phone']))
    {
        $args['purchaser_phone'] = $user->phone;
    }
}

Changelog

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