You are here

function hook_commerce_customer_profile_copy_refresh_alter in Commerce Core 7

Allows modules to add arbitrary AJAX commands to the array returned from the customer profile copy checkbox refresh.

When a customer checks or unchecks a box to copy the relevant information from one customer profile to another, the associated checkout pane gets an AJAX refresh. The form will be rebuilt using the new form state and the AJAX callback of the element that was clicked will be called. For this checkbox it is commerce_customer_profile_copy_refresh().

Instead of just returning the checkout pane to be rendered, this AJAX refresh function returns an array of AJAX commands that includes the necessary form element replacement. However, other modules may want to interact with the refreshed form. They can use this hook to add additional items to the commands array, which is passed to the hook by reference. Note that the form array and form state cannot be altered, just the array of commands.

Parameters

&$commands: The array of AJAX commands used to refresh the customer profile checkout pane with updated form elements.

$form: The rebuilt form array.

$form_state: The form state array from the form.

See also

commerce_customer_profile_copy_refresh()

1 invocation of hook_commerce_customer_profile_copy_refresh_alter()
commerce_customer_profile_copy_refresh in modules/customer/includes/commerce_customer.checkout_pane.inc
Ajax callback: Returns ajax command to refresh customer profile pane.

File

modules/customer/commerce_customer.api.php, line 159
Hooks provided by the Customer module.

Code

function hook_commerce_customer_profile_copy_refresh_alter(&$commands, $form, $form_state) {

  // Display an alert message.
  $commands[] = ajax_command_alert(t('The customer profile checkout pane has been updated.'));
}