You are here

function commerce_avatax_uninstall in Drupal Commerce Connector for AvaTax 7.5

Same name and namespace in other branches
  1. 7.3 commerce_avatax.install \commerce_avatax_uninstall()
  2. 7.4 commerce_avatax.install \commerce_avatax_uninstall()

Implements hook_uninstall().

File

./commerce_avatax.install, line 45
Installation functions for Commerce Avatax module.

Code

function commerce_avatax_uninstall() {
  drupal_load('module', 'commerce_avatax');

  // Delete the Avatax codes Taxonomy.
  if ($vocabulary = taxonomy_vocabulary_machine_name_load('avatax_codes')) {
    taxonomy_vocabulary_delete($vocabulary->vid);
  }
  $fields_to_delete = array(
    COMMERCE_AVATAX_TAX_CODE_FIELD,
    COMMERCE_AVATAX_EXEMPTION_CODE_FIELD,
    COMMERCE_AVATAX_VAT_ID_FIELD,
  );
  foreach ($fields_to_delete as $field_name) {

    // Skip non existing fields.
    if (!field_info_field($field_name)) {
      continue;
    }
    field_delete_field($field_name);
  }

  // Remove all variables defined by Commerce Avatax.
  db_delete('variable')
    ->condition('name', COMMERCE_AVATAX_VAR_PREFIX . '%', 'LIKE')
    ->execute();
}