You are here

commerce_avatax.install in Drupal Commerce Connector for AvaTax 7.3

File

commerce_avatax.install
View source
<?php

/**
 * Implementation of hook_requirements().
 */
function commerce_avatax_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();
  $has_soap = extension_loaded('soap');
  $requirements['commerce_avatax_soap'] = array(
    'title' => $t('SOAP'),
    'value' => $has_soap ? $t('Enabled for AvaTax Calc') : $t('Not found'),
  );
  if (!$has_soap) {
    $requirements['commerce_avatax_soap']['severity'] = REQUIREMENT_ERROR;
    $requirements['commerce_avatax_soap']['description'] = $t('AvaTax requires SOAP to be configured on your server.');
  }
  return $requirements;
}

/**
 * Implements hook_uninstall().
 */
function commerce_avatax_uninstall() {

  // Delete AvaTax variables.
  db_query("DELETE FROM {variable} WHERE name LIKE 'commerce_avatax_%'");
  cache_clear_all('variables', 'cache');

  // Delete AvaTax rules.
  $rules = rules_config_load_multiple(FALSE);
  foreach ($rules as $rule) {
    if (strpos($rule->name, 'commerce_avatax') === 0) {
      rules_config_delete(array(
        $rule->id,
      ));
    }
  }
}

Functions