You are here

function commerce_avatax_address_suggestion_form in Drupal Commerce Connector for AvaTax 7.5

Same name and namespace in other branches
  1. 7.4 commerce_avatax.module \commerce_avatax_address_suggestion_form()

Returns address suggestion form.

1 string reference to 'commerce_avatax_address_suggestion_form'
commerce_avatax_address_compare in includes/commerce_avatax.address.inc
Compare entered address and the validated addresses returned by AvaTax.

File

./commerce_avatax.module, line 1002
AvaTax service integration from Avalara, Inc.

Code

function commerce_avatax_address_suggestion_form($form, &$form_state, $original_address, $suggestions) {
  if (count($suggestions) == 1) {
    $form['info'] = array(
      '#type' => 'markup',
      '#markup' => '<p>' . t('Your shipping address is different from the post office records. We suggest you accept the recommended address to avoid shipping delays.') . '</p>',
    );
  }
  else {
    $form['info'] = array(
      '#type' => 'markup',
      '#markup' => '<p>' . t('Your shipping address is different from the post office records. We suggest you accept one of the recommended addresses to avoid shipping delays.') . '</p>',
    );
  }
  $form['original_address'] = array(
    '#type' => 'markup',
    '#markup' => '<p>' . t('Entered address is:') . '</p>' . theme('commerce_avatax_address', array(
      'address' => $original_address,
    )),
  );
  $options = array();
  foreach ($suggestions as $key => $address) {
    $options[$key] = theme('commerce_avatax_address', array(
      'address' => $address,
    ));
  }
  $form['addresses'] = array(
    '#title' => t('Recommended address'),
    '#type' => 'radios',
    '#options' => $options,
    '#default_value' => '0',
  );
  return $form;
}