You are here

function uc_get_country_data in Ubercart 7.3

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

Returns country data based on the supplied criteria.

Parameters

$match: An associative array of fields to match.

$sort: The field to sort by.

15 calls to uc_get_country_data()
uc_2checkout_form in payment/uc_2checkout/uc_2checkout.module
Form to build the submission to 2Checkout.com.
uc_cybersource_charge in payment/uc_cybersource/uc_cybersource.module
Charges card.
uc_cybersource_hop_form in payment/uc_cybersource/uc_cybersource.module
Defines values to be posted to CyberSource.
uc_cybersource_uc_calculate_tax in payment/uc_cybersource/uc_cybersource.module
Implements hook_uc_calculate_tax().
uc_googleanalytics_ecommerce_js in uc_googleanalytics/uc_googleanalytics.module
Build the e-commerce JS passed to Google Analytics for order tracking.

... See full list

File

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

Code

function uc_get_country_data($match = array(), $sort = 'country_name') {
  $valid_fields = array(
    'country_id',
    'country_name',
    'country_iso_code_2',
    'country_iso_code_3',
    'version',
  );
  if (!is_array($match)) {
    $match = array();
  }
  if (!in_array($sort, $valid_fields)) {
    $sort = 'country_name';
  }
  $query = db_select('uc_countries')
    ->fields('uc_countries')
    ->orderBy($sort);
  if (count($match) > 0) {
    $where = '';
    foreach ($match as $key => $value) {
      if (!in_array($key, $valid_fields)) {
        continue;
      }
      $query
        ->condition($key, $value);
    }
  }
  $countries = $query
    ->execute()
    ->fetchAll(PDO::FETCH_ASSOC);
  return empty($countries) ? FALSE : $countries;
}