You are here

function uc_country_disable in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_store/uc_store.module \uc_country_disable()
  2. 6.2 uc_store/uc_store.admin.inc \uc_country_disable()

Disables a country so it remains installed but is no longer selectable.

Parameters

$country_id: The ISO 3166-1 numeric country code.

1 string reference to 'uc_country_disable'
uc_store_menu in uc_store/uc_store.module
Implements hook_menu().

File

uc_store/uc_store.countries.inc, line 202
Store administration forms for country and address handling.

Code

function uc_country_disable($country_id) {
  $result = db_query("SELECT * FROM {uc_countries} WHERE country_id = :id", array(
    ':id' => $country_id,
  ));
  if ($country = $result
    ->fetchObject()) {
    if ($country->version > 0) {
      db_update('uc_countries')
        ->fields(array(
        'version' => -$country->version,
      ))
        ->condition('country_id', $country_id)
        ->execute();
      drupal_set_message(t('@country disabled.', array(
        '@country' => t($country->country_name),
      )));
    }
    else {
      drupal_set_message(t('@country is already disabled.', array(
        '@country' => t($country->country_name),
      )), 'error');
    }
  }
  else {
    drupal_set_message(t('Attempted to disable an invalid country.'), 'error');
  }
  drupal_goto('admin/store/settings/countries');
}