当前位置: 首页>>代码示例>>PHP>>正文


PHP Lookup::postcodes方法代码示例

本文整理汇总了PHP中Lookup::postcodes方法的典型用法代码示例。如果您正苦于以下问题:PHP Lookup::postcodes方法的具体用法?PHP Lookup::postcodes怎么用?PHP Lookup::postcodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lookup的用法示例。


在下文中一共展示了Lookup::postcodes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:97,代码来源:Shipping.php

示例2: 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');
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:101,代码来源:System.php

示例3: prefixcode

 /**
  * Lookup country state/province by postal code prefix
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @param string $prefix The postal code prefix
  * @param ShoppAddress $Address
  * @return void
  **/
 public static function prefixcode($prefix, ShoppAddress $Address)
 {
     $postcodes = Lookup::postcodes();
     if (!isset($postcodes[$Address->country])) {
         return;
     }
     $codemap =& $postcodes[$Address->country];
     $state = isset($codemap[strtoupper($prefix)]) ? $codemap[$prefix] : false;
     if (is_array($state)) {
         // Handle multiple states in the same postal code prefix. Props msigley
         if (in_array($Address->state, $state)) {
             $state = false;
         } else {
             $state = $state[0];
         }
     }
     if (!$state) {
         return;
     }
     $Address->state = $state;
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:31,代码来源:Address.php


注:本文中的Lookup::postcodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。