You are here

function uc_country_remove_form in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_store/uc_store.admin.inc \uc_country_remove_form()
  2. 7.3 uc_store/uc_store.countries.inc \uc_country_remove_form()
1 string reference to 'uc_country_remove_form'
uc_store_menu in uc_store/uc_store.module
Implementation of hook_menu().

File

uc_store/uc_store.module, line 1144
Contains global Ubercart functions and store administration functionality.

Code

function uc_country_remove_form($country_id) {

  // Fetch the country name from the database.
  $country = db_result(db_query("SELECT country_name FROM {uc_countries} WHERE country_id = %d", $country_id));

  // If orders exist for this country, show a warning message prior to removal.
  if ($_POST['op'] != t('Remove') && module_exists('uc_order')) {
    $count = db_result(db_query("SELECT COUNT(order_id) FROM {uc_orders} WHERE delivery_country = %d OR billing_country = %d", $country_id, $country_id));
    if ($count > 0) {
      drupal_set_message(t('Warning: @count orders were found with addresses in @country. Removing it now will cause errors to show on those order pages. You might consider simply disabling @country instead.', array(
        '@count' => $count,
        '@country' => $country,
      )), 'error');
    }
  }

  // Store the country ID in the form array for processing.
  $form['country_id'] = array(
    '#type' => 'value',
    '#value' => $country_id,
  );
  return confirm_form($form, t('Are you sure you want to remove @country from the system?', array(
    '@country' => $country,
  )), 'admin/store/settings/countries/edit', NULL, t('Remove'));
}