本文整理汇总了PHP中Lookup::regions方法的典型用法代码示例。如果您正苦于以下问题:PHP Lookup::regions方法的具体用法?PHP Lookup::regions怎么用?PHP Lookup::regions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lookup
的用法示例。
在下文中一共展示了Lookup::regions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: region
/**
* Finds the translated region name for a specific region index
*
* @author Jonathan Davis
* @since 1.1
*
* @return string The translated region name
**/
public static function region($id)
{
$r = Lookup::regions();
return $r[$id];
}
示例2: location_menu
public function location_menu($destination = false, $row = 0, $module = false)
{
if (!$module) {
$module = $this->module;
}
$menuarrow = ' ▾';
$tab = str_repeat('⋅', 3) . ' ';
$regions = Lookup::regions();
$countries = Lookup::countries();
$regional_countries = array();
$country_areas = array();
$country_zones = array();
$postcode = false;
$subregions = isset($_POST[$module]['table'][$row]['subregions']);
$selection = array();
$selected = array('region' => '*', 'country' => '', 'area' => '', 'zone' => '');
if (strpos($destination, ',') !== false) {
$selection = explode(',', $destination);
} else {
$selection = array($destination);
}
if ($subregions && isset($_POST[$module]['table'][$row]['destination'])) {
$selection = explode(',', $_POST[$module]['table'][$row]['destination']);
}
if (!is_array($selection)) {
$selection = array($selection);
}
$keys = array_slice(array_keys($selected), 0, count($selection));
$selected = array_merge($selected, array_combine($keys, $selection));
$regional_countries = array_filter($countries, create_function('$c', 'return (\'' . $selected['region'] . '\' === (string)$c[\'region\']);'));
if (!empty($selected['country'])) {
$ca = Lookup::country_areas();
if (isset($ca[$selected['country']])) {
$country_areas = $ca[$selected['country']];
}
$cz = Lookup::country_zones();
if (isset($cz[$selected['country']])) {
$country_zones = $cz[$selected['country']];
}
}
$options = array('*' => __('Anywhere', 'Shopp'));
foreach ($regions as $index => $region) {
if ($index == $selected['region'] && !empty($regional_countries) && ($subregions || !empty($selected['country']))) {
$options[$index] = $region . $menuarrow;
foreach ($regional_countries as $country => $country_data) {
$country_name = $country_data['name'];
if ($country == $selected['country']) {
$postcodes = Lookup::postcodes();
$postcode = isset($postcodes[$selected['country']]);
if (!empty($country_areas) && ($subregions || !empty($selected['area']))) {
$options["{$index},{$country}"] = $country_name . $menuarrow;
$areas = array_keys($country_areas);
foreach ($areas as $area => $area_name) {
if ((string) $area == (string) $selected['area']) {
$zones = array_flip($country_areas[$area_name]);
$zones = array_intersect_key($country_zones, $zones);
$group_name = $area_name . $menuarrow;
$options[$group_name] = array();
// Setup option group for area zones
if (empty($selected['zone'])) {
$selected['zone'] = key($zones);
}
foreach ($zones as $zone => $zone_name) {
$options[$group_name]["{$index},{$country},{$area},{$zone}"] = $zone_name . ', ' . substr($country, 0, 2);
}
// end foreach($country_zones)
} else {
$options["{$index},{$country},{$area}"] = str_repeat(' ', 2) . $area_name;
}
}
// end foreach($areas)
} elseif (!empty($country_zones) && ($subregions || !empty($selected['area']))) {
$options[$country_name] = array();
if (empty($selected['area'])) {
$selected['area'] = key($country_zones);
}
foreach ($country_zones as $zone => $zone_name) {
$options[$country_name]["{$index},{$country},{$zone}"] = $zone_name . ', ' . substr($country, 0, 2);
}
// end foreach($country_zones)
} else {
$options["{$index},{$country}"] = $country_name;
}
} else {
$options["{$index},{$country}"] = $tab . $country_name;
}
}
// end foreach ($regional_countries)
} else {
$options[$index] = $region;
}
}
// end foreach ($regions)
$selected = array_filter($selected, create_function('$i', 'return (\'\' != $i);'));
$selection = join(',', $selected);
return array('options' => $options, 'selection' => $selection, 'postcode' => $postcode);
}
示例3: shiprates
//.........这里部分代码省略.........
$active[$module] = array();
}
$active[$module][(int) $id] = true;
shopp_set_setting('active_shipping', $active);
$this->notice(Shopp::__('Shipping settings saved.'));
}
}
}
$Shipping->settings();
// Load all installed shipping modules for settings UIs
$Shipping->ui();
// Setup setting UIs
$installed = array();
$shiprates = array();
// Registry for activated shipping rate modules
$settings = array();
// Registry of loaded settings for table-based shipping rates for JS
foreach ($Shipping->active as $name => $module) {
if (version_compare($Shipping->modules[$name]->since, '1.2') == -1) {
continue;
}
// Skip 1.1 modules, they are incompatible
$default_name = strtolower($name);
$fullname = $module->methods();
$installed[$name] = $fullname;
if ($module->ui->tables) {
$defaults[$default_name] = $module->ui->settings();
$defaults[$default_name]['name'] = $fullname;
$defaults[$default_name]['label'] = __('Shipping Method', 'Shopp');
}
if (array_key_exists($name, $active)) {
$ModuleSetting = $active[$name];
} else {
continue;
}
// Not an activated shipping module, go to the next one
// Setup shipping service shipping rate entries and settings
if (!is_array($ModuleSetting)) {
$shiprates[$name] = $name;
continue;
}
// Setup shipping calcualtor shipping rate entries and settings
foreach ($ModuleSetting as $id => $m) {
$setting = "{$name}-{$id}";
$shiprates[$setting] = $name;
$settings[$setting] = shopp_setting($setting);
$settings[$setting]['id'] = $setting;
$settings[$setting] = array_merge($defaults[$default_name], $settings[$setting]);
if (isset($settings[$setting]['table'])) {
usort($settings[$setting]['table'], array('ShippingFramework', '_sorttier'));
foreach ($settings[$setting]['table'] as &$r) {
if (isset($r['tiers'])) {
usort($r['tiers'], array('ShippingFramework', '_sorttier'));
}
}
}
}
}
if (isset($_REQUEST['id'])) {
$edit = $_REQUEST['id'];
$id = false;
if (strpos($edit, '-') !== false) {
list($module, $id) = explode('-', $edit);
} else {
$module = $edit;
}
if (isset($Shipping->active[$module])) {
$Shipper = $Shipping->get($module);
if (!$Shipper->singular) {
$Shipper->setting($id);
$Shipper->initui($Shipping->modules[$module]->name);
// Re-init setting UI with loaded settings
}
$editor = $Shipper->ui();
}
}
asort($installed);
$countrydata = Lookup::countries();
$countries = $regionmap = $postcodes = array();
$postcodedata = Lookup::postcodes();
foreach ($countrydata as $code => $country) {
$countries[$code] = $country['name'];
if (!isset($regionmap[$country['region']])) {
$regionmap[$country['region']] = array();
}
$regionmap[$country['region']][] = $code;
if (isset($postcodedata[$code])) {
if (!isset($postcodes[$code])) {
$postcodes[$code] = array();
}
$postcodes[$code] = true;
}
}
unset($countrydata);
unset($postcodedata);
$lookup = array('regions' => array_merge(array('*' => __('Anywhere', 'Shopp')), Lookup::regions()), 'regionmap' => $regionmap, 'countries' => $countries, 'areas' => Lookup::country_areas(), 'zones' => Lookup::country_zones(), 'postcodes' => $postcodes);
$ShippingTemplates = new TemplateShippingUI();
add_action('shopp_shipping_module_settings', array($Shipping, 'templates'));
include $this->ui('shiprates.php');
}
示例4: locate
/**
* Sets the address location for calculating tax and shipping estimates
*
* @author Jonathan Davis
* @since 1.1
*
* @return void
**/
public function locate($data = false)
{
$base = shopp_setting('base_operations');
$markets = shopp_setting('target_markets');
$countries = Lookup::countries();
$regions = Lookup::regions();
if ($data) {
$this->updates($data);
}
if (empty($this->country)) {
// If the target markets are set to single country, use that target as default country
// otherwise default to the base of operations for tax and shipping estimates
if (1 == count($markets)) {
$this->country = key($markets);
} else {
$this->country = $base['country'];
}
}
// Update state if postcode changes for tax updates
if (isset($this->postcode)) {
$this->postmap();
}
$this->region = false;
if (isset($countries[$this->country]) && isset($regions[$countries[$this->country]['region']])) {
$this->region = $regions[$countries[$this->country]['region']];
}
}
示例5: shipping
/**
* Renders the shipping settings screen and processes updates
*
* @since 1.1
*
* @return void
**/
function shipping () {
global $Ecart;
if ( !(current_user_can('manage_options') && current_user_can('ecart_settings_shipping')) )
wp_die(__('You do not have sufficient permissions to access this page.'));
if (!empty($_POST['save'])) {
check_admin_referer('ecart-settings-shipping');
// Sterilize $values
foreach ($_POST['settings']['shipping_rates'] as $i => &$method) {
$method['name'] = stripslashes($method['name']);
foreach ($method as $key => &$mr) {
if (!is_array($mr)) continue;
foreach ($mr as $id => &$v) {
if ($v == ">" || $v == "+" || $key == "services") continue;
$v = floatvalue($v);
}
}
}
$_POST['settings']['order_shipfee'] = floatvalue($_POST['settings']['order_shipfee']);
$this->settings_save();
$updated = __('Shipping settings saved.','Ecart');
// Reload the currently active shipping modules
$active = $Ecart->Shipping->activated();
$Ecart->Shipping->settings();
$Errors = &EcartErrors();
do_action('ecart_verify_shipping_services');
if ($Errors->exist()) {
// Get all addon related errors
$failures = $Errors->level(ECART_ADDON_ERR);
if (!empty($failures)) {
$updated = __('Shipping settings saved but there were errors: ','Ecart');
foreach ($failures as $error)
$updated .= '<p>'.$error->message(true,true).'</p>';
}
}
}
$Ecart->Shipping->settings();
$methods = $Ecart->Shipping->methods;
$base = $Ecart->Settings->get('base_operations');
$regions = Lookup::regions();
$region = $regions[$base['region']];
$useRegions = $Ecart->Settings->get('shipping_regions');
$areas = Lookup::country_areas();
if (is_array($areas[$base['country']]) && $useRegions == "on")
$areas = array_keys($areas[$base['country']]);
else $areas = array($base['country'] => $base['name']);
unset($countries,$regions);
$rates = $Ecart->Settings->get('shipping_rates');
if (!empty($rates)) ksort($rates);
$lowstock = $Ecart->Settings->get('lowstock_level');
if (empty($lowstock)) $lowstock = 0;
include(ECART_ADMIN_PATH."/settings/shipping.php");
}
示例6: upgrade_120
public function upgrade_120()
{
// 1.2 schema changes
$db_version = ShoppSettings::dbversion();
if ($db_version < 1120) {
$this->upschema('schema-120.sql');
}
global $wpdb;
// Clear the shopping session table
$shopping_table = ShoppDatabaseObject::tablename('shopping');
sDB::query("DELETE FROM {$shopping_table}");
if ($db_version <= 1140) {
$summary_table = ShoppDatabaseObject::tablename('summary');
// Force summaries to rebuild
sDB::query("UPDATE {$summary_table} SET modified='0000-00-00 00:00:01'");
}
$purchase_table = ShoppDatabaseObject::tablename('purchase');
sDB::query("UPDATE {$purchase_table} SET txnstatus='captured' WHERE txnstatus='CHARGED'");
sDB::query("UPDATE {$purchase_table} SET txnstatus='voided' WHERE txnstatus='VOID'");
if ($db_version <= 1130) {
// Move settings to meta table
$meta_table = ShoppDatabaseObject::tablename('meta');
$setting_table = ShoppDatabaseObject::tablename('setting');
sDB::query("INSERT INTO {$meta_table} (context, type, name, value, created, modified) SELECT 'shopp', 'setting', name, value, created, modified FROM {$setting_table}");
// Clean up unnecessary duplicate settings
shopp_rmv_setting('data_model');
shopp_rmv_setting('updates');
shopp_rmv_setting('shopp_setup');
shopp_rmv_setting('maintenance');
// Re-load the Shopp settings registry
ShoppSettings()->load();
shopp_set_setting('maintenance', 'on');
$db_version = intval(shopp_setting('db_version'));
// Force inventory in 1.2 on to mimic 1.1 behavior (inventory tracking always on)
shopp_set_setting('inventory', 'on');
// Convert Shopp 1.1.x shipping settings to Shopp 1.2-compatible settings
$active_shipping = array();
$regions = Lookup::regions();
$countries = Lookup::countries();
$areas = Lookup::country_areas();
$calcnaming = array('FlatRates::order' => 'OrderRates', 'FlatRates::item' => 'ItemRates', 'FreeOption' => 'FreeOption', 'ItemQuantity::range' => 'ItemQuantity', 'OrderAmount::range' => 'OrderAmount', 'OrderWeight::range' => 'OrderWeight');
$shipping_rates = shopp_setting('shipping_rates');
foreach ((array) $shipping_rates as $id => $old) {
if (isset($calcnaming[$old['method']])) {
// Add to active setting registry for that calculator class
$calcname = $calcnaming[$old['method']];
if (!isset(${$calcname}) && !is_array(${$calcname})) {
${$calcname} = array();
}
${$calcname}[] = true;
$active_shipping[$calcname] = ${$calcname};
// Define the setting name
$settingid = end(array_keys(${$calcname}));
$setting_name = $calcname . '-' . $settingid;
} else {
// Not a calculator, must be a shipping rate provider module, add it to the active roster
$active_shipping[$old['name']] = true;
continue;
}
$new = array();
$new['label'] = $old['name'];
list($new['mindelivery'], $new['maxdelivery']) = explode('-', $old['delivery']);
$new['fallback'] = 'off';
// Not used in legacy settings
$oldkeys = array_keys($old);
$old_destinations = array_diff($oldkeys, array('name', 'delivery', 'method', 'max'));
$table = array();
foreach ($old_destinations as $old_dest) {
$_ = array();
if ('Worldwide' == $old_dest) {
$d = '*';
}
$region = array_search($old_dest, $regions);
if (false !== $region) {
$d = "{$region}";
}
if (isset($countries[$old_dest])) {
$country = $countries[$old_dest];
$region = $country['region'];
$d = "{$region}, {$old_dest}";
}
foreach ($areas as $countrykey => $countryarea) {
$areakeys = array_keys($countryarea);
$area = array_search($old_dest, $areakeys);
if (false !== $area) {
$country = $countrykey;
$region = $countries[$countrykey]['region'];
$area = $areakeys[$area];
$d = "{$region}, {$country}, {$area}";
break;
}
}
$_['destination'] = $d;
$_['postcode'] = '*';
// Postcodes are new in 1.2, hardcode to wildcard
if (isset($old['max']) && !empty($old['max'])) {
// Capture tiered rates
$_['tiers'] = array();
$prior = 1;
foreach ($old['max'] as $index => $oldthreshold) {
//.........这里部分代码省略.........
示例7: parse_location
public static function parse_location($destination)
{
$selected = array('region' => '*', 'country' => '', 'area' => '', 'zone' => '');
$selection = array();
if (strpos($destination, ',') !== false) {
$selection = explode(',', $destination);
} else {
$selection = array($destination);
}
if (!is_array($selection)) {
$selection = array($selection);
}
$keys = array_slice(array_keys($selected), 0, count($selection));
$selected = array_merge($selected, array_combine($keys, $selection));
extract($selected);
foreach ($selected as $name => &$value) {
if ($value == '') {
continue;
}
switch ($name) {
case 'region':
if ('*' == $value) {
$value = __('Worldwide', 'Shopp');
} else {
$regions = Lookup::regions();
if (isset($regions[$value])) {
$value = $regions[$value];
}
}
break;
case 'country':
$countries = Lookup::countries();
$selected['countrycode'] = $value;
if (isset($countries[$value])) {
$value = $countries[$value]['name'];
}
break;
case 'zone':
$zones = Lookup::country_zones();
if (isset($zones[$country])) {
$zones = $zones[$country];
}
if (isset($zones[$value])) {
$value = $zones[$value];
}
break;
}
}
return $selected;
}
示例8: destination
/**
* Sets the shipping address location for calculating
* shipping estimates.
*
* @since 1.1
*
* @return void Description...
**/
function destination ($data=false) {
global $Ecart;
$base = $Ecart->Settings->get('base_operations');
$countries = Lookup::countries();
$regions = Lookup::regions();
if ($data) $this->updates($data);
// Update state if postcode changes for tax updates
if (isset($this->postcode))
$this->postarea();
if (empty($this->country))
$this->country = $base['country'];
$this->region = false;
if (isset($regions[$countries[$this->country]['region']]))
$this->region = $regions[$countries[$this->country]['region']];
}