function uc_country_remove_form in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_store/uc_store.module \uc_country_remove_form()
- 6.2 uc_store/uc_store.admin.inc \uc_country_remove_form()
Form to completely remove a country.
Parameters
$country_id: The ISO 3166-1 numeric country code.
See also
uc_country_remove_form_submit()
1 string reference to 'uc_country_remove_form'
- uc_store_menu in uc_store/
uc_store.module - Implements hook_menu().
File
- uc_store/
uc_store.countries.inc, line 261 - Store administration forms for country and address handling.
Code
function uc_country_remove_form($form, &$form_state, $country_id) {
// Fetch the country name from the database.
$country = t(db_query("SELECT country_name FROM {uc_countries} WHERE country_id = :id", array(
':id' => $country_id,
))
->fetchField());
// If orders exist for this country, show a warning message prior to removal.
if (isset($form_state['triggering_element']) && $form_state['triggering_element']['#value'] != t('Remove') && module_exists('uc_order')) {
$count = db_query("SELECT COUNT(order_id) FROM {uc_orders} WHERE delivery_country = :delivery_country OR billing_country = :billing_country", array(
':delivery_country' => $country_id,
':billing_country' => $country_id,
))
->fetchField();
if ($count > 0) {
drupal_set_message(t('Warning: @count orders were found with addresses in this country. Removing this country now will cause errors to show on those order pages. You might consider simply disabling this country instead.', array(
'@count' => $count,
)), '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', NULL, t('Remove'));
}