多嚿魚教室

Opencart優化技巧

In Opencart Admin panel, this is an Autocomplete function for entry of product attributes. When user types in something into the text field of product attribute, a word box of defined product attributes will appear below the field to let user click that wanted to save the typing time.

However, if the user does not click the word box and type a complete word by oneself, the Opencart system will not save the product attribute data the user types. In fact, the Autocomplete function wanted to prevent user inputting undefined product attributes. In other words, the system does not record what the user types but just detects which item the user clicks in the word box. The Autocomplete function is user-unfriendly, especially there are many product attributes defined.

To simplify the entry of product attributes, I have programmed a vQmod plug-in to change the text field into drop-down list so that the user does not need to type anything.

If vQmod have been installed in your Opencart system,
click the below fish and save the XML script into the directory [vqmod/xml].


<p>
&#60;!--<br />
Make sure that you have properly installed Opencart vQmod.<br />
Copy this page of script.<br />
Save as a .xml file of utf-8 encoding without BOM into the directory [vqmod/xml].<br />
Name the file as you like.<br />
--&gt;</p>
<pre contenteditable="true">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;modification&gt;
 &lt;id&gt;Display attribute choices of products in drop-down list&lt;/id&gt;
 &lt;version&gt;1.1.0&lt;/version&gt;
 &lt;author&gt;Flexidigi Solution Ltd.&lt;/author&gt;
 &lt;file name=&quot;admin/model/catalog/product.php&quot;&gt;
  &lt;operation&gt;
   &lt;search position=&quot;after&quot;&gt;&lt;![CDATA[class ModelCatalogProduct extends Model {]]&gt;&lt;/search&gt;
   &lt;add&gt;&lt;![CDATA[
 public function get_all_attribute_names() {
  $query = $this-&gt;db-&gt;query(&quot;SELECT attribute_group_id, attribute_id , name FROM &quot; . DB_PREFIX . &quot;attribute_description NATURAL JOIN &quot; . DB_PREFIX . &quot;attribute WHERE language_id = '&quot; . (int)$this-&gt;config-&gt;get('config_language_id') . &quot;' order by attribute_group_id DESC&quot;);
  
  return $query-&gt;rows;
 }
 public function get_all_attribute_group_names() {
  $query = $this-&gt;db-&gt;query(&quot;SELECT attribute_group_id , name FROM &quot; . DB_PREFIX . &quot;attribute_group_description WHERE language_id = '&quot; . (int)$this-&gt;config-&gt;get('config_language_id') . &quot;' order by attribute_group_id DESC&quot;);
  
  return $query-&gt;rows;
 }  
   ]]&gt;&lt;/add&gt;
  &lt;/operation&gt;
 &lt;/file&gt;
 &lt;file name=&quot;admin/controller/catalog/product.php&quot;&gt;
  &lt;operation&gt;
   &lt;search position=&quot;after&quot;&gt;&lt;![CDATA[private function getForm() {]]&gt;&lt;/search&gt;
   &lt;add&gt;&lt;![CDATA[
     $this-&gt;data['attribute_names'] = array();
  $results = $this-&gt;model_catalog_product-&gt;get_all_attribute_names();
  foreach ($results as $result) {
   $this-&gt;data['attribute_names'][] = array(
    'name' =&gt; $result['name'],
    'attribute_id' =&gt; $result['attribute_id'],
    'attribute_group_id' =&gt; $result['attribute_group_id']);
  }
  $this-&gt;data['attribute_group_names'] = array();
  $results = $this-&gt;model_catalog_product-&gt;get_all_attribute_group_names();
  foreach ($results as $result) {
   $this-&gt;data['attribute_group_names'][] = array(
    'name' =&gt; $result['name'],
    'attribute_group_id' =&gt; $result['attribute_group_id']);
  }
   ]]&gt;&lt;/add&gt;
  &lt;/operation&gt;
 &lt;/file&gt;
 &lt;file name=&quot;admin/view/template/catalog/product_form.tpl&quot;&gt;
 &lt;!-- Show all existing Product attributes --&gt;
  &lt;operation&gt;
   &lt;search position=&quot;before&quot; offset=&quot;1&quot;&gt;&lt;![CDATA[&lt;div id=&quot;tab-option&quot;&gt;]]&gt;&lt;/search&gt;
   &lt;add&gt;&lt;![CDATA[
   &lt;aside&gt;
   &lt;header style=&quot;margin-right: 3em;float:left;font-size:1.5em&quot;&gt;&lt;?php echo $entry_attribute; ?&gt;&lt;/header&gt;
            &lt;?php foreach ($attribute_group_names as $all_attribute_group){ ?&gt;
            &lt;details style=&quot;border:#6FF solid thin; margin-right: 3em; padding:1em;float:left;&quot;&gt;
            &lt;summary style=&quot;text-decoration:underline;&quot;&gt;&lt;?php print($all_attribute_group['name']); ?&gt;&lt;/summary&gt;
        &lt;ul style=&quot;list-style-type:none;&quot; title=&quot;&lt;?php echo $all_attribute_group['name']; ?&gt;&quot;&gt;
        &lt;?php foreach ($attribute_names as $all_attribute){ 
   if($all_attribute['attribute_group_id']==$all_attribute_group['attribute_group_id']) { ?&gt;
         &lt;li&gt;&lt;?php print($all_attribute['name']); ?&gt;&lt;/li&gt;
        &lt;?php } } ?&gt;
        &lt;/ul&gt;
        &lt;/details&gt;
        &lt;?php } ?&gt;
        &lt;/aside&gt;
   ]]&gt;&lt;/add&gt;
  &lt;/operation&gt;
  &lt;operation&gt;
   &lt;search position=&quot;replace&quot;&gt;&lt;![CDATA[&lt;input type=&quot;text&quot; name=&quot;product_attribute[' + attribute_row + '][name]&quot;]]&gt;&lt;/search&gt;
   &lt;add&gt;&lt;![CDATA[';
   html += '&lt;select title=&quot;Product attributes&quot; name=&quot;product_attribute[' + attribute_row + '][name]&quot; onchange=&quot;document.getElementsByName(\'product_attribute[' + attribute_row + '][attribute_id]\')[0].value=this.options[this.selectedIndex].value;&quot;&gt;';
   html += '&lt;option value=&quot;&quot; selected=&quot;selected&quot;&gt;&lt;?php echo $text_select; ?&gt;&lt;/option&gt;';
  &lt;?php foreach ($attribute_group_names as $all_attribute_group){ ?&gt;
  html += '&lt;optgroup label=&quot;&lt;?php echo $all_attribute_group['name']; ?&gt;&quot;&gt;';
  &lt;?php foreach ($attribute_names as $all_attribute){ 
   if($all_attribute['attribute_group_id']==$all_attribute_group['attribute_group_id']) { ?&gt;
   html += '&lt;option value=&quot;&lt;?php echo $all_attribute['attribute_id']; ?&gt;&quot;&gt;&lt;?php print($all_attribute['name']); ?&gt;&lt;/option&gt;';
  &lt;?php } } ?&gt;
  html += '&lt;/optgroup&gt;';
  &lt;?php } ?&gt;
 html += '    &lt;/select&gt;';
   html += '&lt;input style=&quot;visibility:hidden&quot; list=&quot;attribute_list&quot; type=&quot;text&quot; name=&quot;product_attribute[' + attribute_row + '][name]&quot;]]&gt;&lt;/add&gt;
  &lt;/operation&gt;
 &lt;/file&gt;
&lt;/modification&gt;
</pre>
唔識英文?
自己查字典啦!

我在Opencart後台用CKEditor編輯文章,想插入圖片,於是用CKEditor上傳圖片,但失敗了。到底是甚麼一回事?

以下是錯誤的圖片上傳示範:

  1. 在CKEditor按「影像」,「影像屬性」視窗會彈出。
  2. 按「上傳」標籤,再按「瀏覽...」。
  3. 挑選一個檔案,按「開啟舊檔」。
  4. 按「上傳至伺服器」。
  5. 出錯了!沒有圖片上傳到Opencart伺服器。
上載唔到圖片
有乜叉用!

CKEditor本身不是用來上傳檔案,要插入圖片就要配合檔案上傳工具(file manager)。CKFinder是CKEditor的官方搭檔,專門配合CKEditor上傳圖片。
CKFinder file manager

不過,Opencart並沒有安裝CKFinder,因為Opencart本身已經有檔案上傳工具“Image Manager”。


Finding Solution

正確的圖片上傳方法:

  1. 在CKEditor按「影像」,「影像屬性」視窗會彈出。
  2. 按「影像資訊」標籤,再「瀏覽伺服器端」,“Image Manager”視窗會彈出。
  3. 按“Upload”,檔案瀏覽器會彈出。
  4. 挑選需要的圖片檔案,按「開啟舊檔」。
  5. 上傳完成後,所需圖片會出現在“Image Manager”,雙擊圖片。
  6. 在「影像資訊」輸入有關設定,按「確定」完成圖片插入。

原來Opencart已經有圖片上載工具。但是既然CKEditor的「上傳」是無效,怎樣防止其他人再用?

CKEditor的「上傳」標籤十分誤導用家,既然是失效的,就應該隱藏掉。

隱藏「上傳」標籤的步驟:

  1. 到安裝了Opencart的伺服器,開啟路徑[admin/view/javascript/ckeditor/plugins/image/dialogs]。
  2. 編輯[image.js],搜尋並刪除以下程式碼,然後儲存檔案:
    {id:'Upload',hidden:true,filebrowser:'uploadButton',label:b.lang.image.upload,elements:[{type:'file',id:'upload',label:b.lang.image.btnUpload,style:'height:40px',size:38},{type:'fileButton',id:'uploadButton',filebrowser:'info:txtUrl',label:b.lang.image.btnUpload,'for':['Upload','upload']}]},
    
  3. 在CKEditor按「影像」,「影像屬性」視窗會彈出。「上傳」標籤不見了。

Opencart後台內置了CKEditor,讓用家以所見即所得方式編輯文本,例如 product 和 category 的 description。

不過,Opencart和CKEditor的版本更新並不同步,所以用家要自行安裝新版本的CKEditor到Opencart。


為什麼要使用新版本的CKEditor?
怎樣安裝新版本的CKEditor到Opencart?

HTML的最新版本——HTML5在網絡越來越普及,而新版本的CKEditor已支援HTML5的新標籤,包括<article><section><header>等等。另外,新版本有糾正錯誤和新增功能。

做乜叉嘢?


以下方法適用於Opencart v1.5.1.3

更新步驟:

  1. CKEditor官網下載最新版本的CKEditor,並解壓縮出來。
  2. 打開ckeditor文件夾,將多餘的“_samples”和“_source”文件夾刪除。
  3. 到安裝了Opencart的伺服器,開啟[admin/view/javascript/ckeditor]路徑,下載“config.js”和“contents.css”,儲存到剛才解壓縮出來的ckeditor文件夾,覆蓋掉原有的檔案。
  4. 將新版本的ckeditor文件夾上傳到伺服器,覆蓋掉舊版本的ckeditor文件夾即可。

本文最後更新日期:2012年3月12日

Opencart的註冊表格有超過200個國家和特殊政區可供選擇,真是他媽的詳盡!連南極洲都有,以便你將網店生意拓展到企鵝族群。

但是,光找國家名稱眼睛都看到脫窗了 。
若果將國家和特殊政區按世界七大洲排序,就可以方便客戶快速揀選。

咁叉麻煩呀!


以下修改方法適用於Opencart v1.5.1.3
以下國家和地區的資料源自《維基百科》

修改程式方法:

  1. 分別編輯以下檔案:
    • [catalog/view/theme/default/template/account/address_form.tpl]
    • [catalog/view/theme/default/template/account/register.tpl]
    • [catalog/view/theme/default/template/affiliate/edit.tpl]
    • [catalog/view/theme/default/template/affiliate/register.tpl]
    • [catalog/view/theme/default/template/checkout/address.tpl]
    • [catalog/view/theme/default/template/checkout/guest.tpl]
    • [catalog/view/theme/default/template/checkout/guest_shipping.tpl]
    • [catalog/view/theme/default/template/checkout/register.tpl ]
    • [catalog/view/theme/default/template/total/shipping.tpl]
  2. 搜索以下程式碼:
    <?php foreach ($countries as $country) { ?>
                  <?php if ($country['country_id'] == $country_id) { ?>
                  <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
  3. 將以上程式碼替換為以下程式碼:
    <?php $countries_sort_by_continent=array(
      array( 'name' => 'Asia','iso_code_2' => array(
      "AF" /*Afghanistan, Islamic Republic of阿富汗伊斯蘭共和國*/ ,
      "AZ" /*Azerbaijan, Republic of阿塞拜疆共和國*/ ,
      "BH" /*Bahrain, Kingdom of巴林王國*/ ,
      "BD" /*Bangladesh, People's Republic of孟加拉國*/ ,
      "AM" /*Armenia, Republic of亞美尼亞共和國*/ ,
      "BT" /*Bhutan, Kingdom of不丹王國*/ ,
      "IO" /*British Indian Ocean Territory (Chagos Archipelago)英屬印度洋領地(查戈斯群島)*/ ,
      "BN" /*Brunei Darussalam汶萊*/ ,
      "MM" /*Myanmar, Union of緬甸聯盟*/ ,
      "KH" /*Cambodia, Kingdom of柬埔寨王國*/ ,
      "LK" /*Sri Lanka, Democratic Socialist Republic of斯里蘭卡民主社會主義共和國*/ ,
      "CN" /*China, People's Republic of中華人民共和國*/ ,
      "TW" /*Taiwan台灣*/ ,
      "CX" /*Christmas Island聖誕島*/ ,
      "CC" /*Cocos (Keeling) Islands科科斯(基林)群島*/ ,
      "CY" /*Cyprus, Republic of塞浦路斯共和國*/ ,
      "GE" /*Georgia格魯吉亞*/ ,
      "PS" /*Palestinian Territory, Occupied被佔巴勒斯坦領土*/ ,
      "HK" /*Hong Kong 香港*/ ,
      "IN" /*India, Republic of印度共和國*/ ,
      "ID" /*Indonesia, Republic of印度尼西亞共和國*/ ,
      "IR" /*Iran, Islamic Republic of伊朗伊斯蘭共和國*/ ,
      "IQ" /*Iraq, Republic of伊拉克共和國*/ ,
      "IL" /*Israel, State of以色列*/ ,
      "JP" /*Japan日本*/ ,
      "KZ" /*Kazakhstan, Republic of哈薩克斯坦共和國*/ ,
      "JO" /*Jordan, Hashemite Kingdom of約旦哈希姆王國*/ ,
      "KP" /*Korea, Democratic People's Republic of朝鮮民主主義人民共和國*/ ,
      "KR" /*Korea, Republic of大韓民國*/ ,
      "KW" /*Kuwait, State of科威特國家*/ ,
      "KG" /*Kyrgyz Republic吉爾吉斯共和國*/ ,
      "LA" /*Lao People's Democratic Republic老撾人民民主共和國*/ ,
      "LB" /*Lebanon, Lebanese Republic黎巴嫩*/ ,
      "MO" /*Macao 澳門*/ ,
      "MY" /*Malaysia馬來西亞*/ ,
      "MV" /*Maldives, Republic of馬爾代夫共和國*/ ,
      "MN" /*Mongolia蒙古*/ ,
      "OM" /*Oman, Sultanate of阿曼蘇丹國*/ ,
      "NP" /*Nepal, State of尼泊爾國家*/ ,
      "PK" /*Pakistan, Islamic Republic of巴基斯坦伊斯蘭共和國*/ ,
      "PH" /*Philippines, Republic of the菲律賓共和國*/ ,
      "TL" /*Timor-Leste, Democratic Republic of東帝汶民主共和國*/ ,
      "QA" /*Qatar, State of卡塔爾*/ ,
      "RU" /*Russian Federation俄羅斯聯邦*/ ,
      "SA" /*Saudi Arabia, Kingdom of沙特阿拉伯王國*/ ,
      "SG" /*Singapore, Republic of新加坡*/ ,
      "VN" /*Vietnam, Socialist Republic of越南社會主義共和國*/ ,
      "SY" /*Syrian Arab Republic阿拉伯敘利亞共和國*/ ,
      "TJ" /*Tajikistan, Republic of塔吉克斯坦共和國*/ ,
      "TH" /*Thailand, Kingdom of 泰國*/ ,
      "AE" /*United Arab Emirates阿拉伯聯合酋長國*/ ,
      "TR" /*Turkey, Republic of土耳其共和國*/ ,
      "TM" /*Turkmenistan土庫曼斯坦*/ ,
      "UZ" /*Uzbekistan, Republic of烏茲別克斯坦共和國*/ ,
      "YE" /*Yemen也門*/)
      ),array( 'name' => 'Europe','iso_code_2' => array(
      "AL" /*Albania, Republic of阿爾巴尼亞共和國*/ ,
      "AD" /*Andorra, Principality of安道​​爾公國的*/ ,
      "AZ" /*Azerbaijan, Republic of阿塞拜疆共和國*/ ,
      "AT" /*Austria, Republic of奧地利共和國*/ ,
      "AM" /*Armenia, Republic of亞美尼亞共和國*/ ,
      "BE" /*Belgium, Kingdom of比利時王國*/ ,
      "BA" /*Bosnia and Herzegovina波斯尼亞和黑塞哥維那*/ ,
      "BG" /*Bulgaria, Republic of保加利亞共和國*/ ,
      "BY" /*Belarus, Republic of白俄羅斯共和國*/ ,
      "HR" /*Croatia, Republic of克羅地亞*/ ,
      "CY" /*Cyprus, Republic of塞浦路斯共和國*/ ,
      "CZ" /*Czech Republic捷克共和國*/ ,
      "DK" /*Denmark, Kingdom of丹麥王國*/ ,
      "EE" /*Estonia, Republic of愛沙尼亞共和國*/ ,
      "FO" /*Faroe Islands法羅群島*/ ,
      "FI" /*Finland, Republic of芬蘭共和國*/ ,
      "AX" /*Åland Islands奧蘭群島*/ ,
      "FR" /*France, French Republic法國*/ ,
      "GE" /*Georgia格魯吉亞*/ ,
      "DE" /*Germany, Federal Republic of德意志聯邦共和國*/ ,
      "GI" /*Gibraltar直布羅陀*/ ,
      "GR" /*Greece, Hellenic Republic希臘*/ ,
      "VA" /*Holy See (Vatican City State)羅馬教廷(梵蒂岡城國)*/ ,
      "HU" /*Hungary, Republic of匈牙利共和國*/ ,
      "IS" /*Iceland, Republic of冰島共和國*/ ,
      "IE" /*Ireland愛爾蘭*/ ,
      "IT" /*Italy, Italian Republic意大利*/ ,
      "KZ" /*Kazakhstan, Republic of哈薩克斯坦共和國*/ ,
      "LV" /*Latvia, Republic of拉脫維亞共和國*/ ,
      "LI" /*Liechtenstein, Principality of列支敦士登公國的*/ ,
      "LT" /*Lithuania, Republic of立陶宛共和國*/ ,
      "LU" /*Luxembourg, Grand Duchy of盧森堡大公國*/ ,
      "MT" /*Malta, Republic of馬耳他共和國*/ ,
      "MC" /*Monaco, Principality of摩納哥公國的*/ ,
      "MD" /*Moldova, Republic of摩爾多瓦共和國*/ ,
      "ME" /*Montenegro, Republic of黑山共和國*/ ,
      "NL" /*Netherlands, Kingdom of the荷蘭王國*/ ,
      "NO" /*Norway, Kingdom of挪威王國*/ ,
      "PL" /*Poland, Republic of波蘭共和國*/ ,
      "PT" /*Portugal, Portuguese Republic葡萄牙*/ ,
      "RO" /*Romania羅馬尼亞*/ ,
      "RU" /*Russian Federation俄羅斯聯邦*/ ,
      "SM" /*San Marino, Republic of聖馬力諾共和國*/ ,
      "RS" /*Serbia, Republic of塞爾維亞共和國*/ ,
      "SK" /*Slovakia (Slovak Republic)斯洛伐克(斯洛伐克共和國)*/ ,
      "SI" /*Slovenia, Republic of斯洛文尼亞共和國*/ ,
      "ES" /*Spain, Kingdom of西班牙王國*/ ,
      "SJ" /*Svalbard , Jan Mayen Islands斯瓦爾巴群島和揚馬​​延島*/ ,
      "SE" /*Sweden, Kingdom of瑞典王國*/ ,
      "CH" /*Switzerland, Swiss Confederation瑞士*/ ,
      "TR" /*Turkey, Republic of土耳其共和國*/ ,
      "UA" /*Ukraine烏克蘭*/ ,
      "MK" /*Macedonia, Republic of馬其頓共和國*/ ,
      "GB" /*United Kingdom of Great Britain , Northern Ireland大不列顛及北愛爾蘭聯合王國*/ ,
      "GG" /*Guernsey, Bailiwick of根西島*/ ,
      "JE" /*Jersey, Bailiwick of 澤西島*/ ,
      "IM" /*Isle of Man馬恩島*/)
      ),array( 'name' => 'North America','iso_code_2' => array(
      "AG" /*Antigua and Barbuda安提瓜和巴布達*/ ,
      "BS" /*Bahamas, Commonwealth of the巴哈馬,英聯邦*/ ,
      "BB" /*Barbados巴巴多斯*/ ,
      "BM" /*Bermuda百慕大*/ ,
      "BZ" /*Belize伯利茲*/ ,
      "VG" /*British Virgin Islands英屬維爾京群島*/ ,
      "CA" /*Canada加拿大*/ ,
      "KY" /*Cayman Islands開曼群島*/ ,
      "CR" /*Costa Rica, Republic of哥斯達黎加共和國*/ ,
      "CU" /*Cuba, Republic of古巴共和國*/ ,
      "DM" /*Dominica, Commonwealth of多米尼加聯邦*/ ,
      "DO" /*Dominican Republic多米尼加共和國*/ ,
      "SV" /*El Salvador, Republic of薩爾瓦多共和國*/ ,
      "GL" /*Greenland格陵蘭*/ ,
      "GD" /*Grenada格林納達*/ ,
      "GP" /*Guadeloupe瓜德羅普島*/ ,
      "GT" /*Guatemala, Republic of危地馬拉共和國*/ ,
      "HT" /*Haiti, Republic of海地共和國*/ ,
      "HN" /*Honduras, Republic of洪都拉斯共和國*/ ,
      "JM" /*Jamaica牙買加*/ ,
      "MQ" /*Martinique馬提尼克島*/ ,
      "MX" /*Mexico, United Mexican States墨西哥*/ ,
      "MS" /*Montserrat蒙特塞拉特*/ ,
      "AN" /*Netherlands Antilles荷屬安的列斯*/ ,
      "CW" /*Curaçao庫拉索島*/ ,
      "AW" /*Aruba阿魯巴*/ ,
      "SX" /*Sint Maarten (Netherlands)聖馬丁島(荷蘭)*/ ,
      "BQ" /*Bonaire, Sint Eustatius and Saba博內爾島*/ ,
      "NI" /*Nicaragua, Republic of尼加拉瓜共和國*/ ,
      "UM" /*United States Minor Outlying Islands美國本土外小島嶼*/ ,
      "PA" /*Panama, Republic of巴拿馬共和國*/ ,
      "PR" /*Puerto Rico, Commonwealth of波多黎各聯邦*/ ,
      "BL" /*Saint Barthelemy聖巴泰勒米*/ ,
      "KN" /*Saint Kitts and Nevis, Federation of聖基茨和尼維斯聯邦*/ ,
      "AI" /*Anguilla安圭拉*/ ,
      "LC" /*Saint Lucia聖盧西亞*/ ,
      "MF" /*Saint Martin聖馬丁*/ ,
      "PM" /*Saint Pierre and Miquelon聖皮埃爾和密克隆*/ ,
      "VC" /*Saint Vincent and the Grenadines聖文森特和格林納丁斯*/ ,
      "TT" /*Trinidad and Tobago, Republic of特里尼達和多巴哥共和國*/ ,
      "TC" /*Turks and Caicos Islands特克斯和凱科斯群島*/ ,
      "US" /*United States of America美國美國*/ ,
      "VI" /*United States Virgin Islands美屬維爾京群島*/)
      ),array( 'name' => 'Oceania','iso_code_2' => array(
      "AS" /*American Samoa美屬薩摩亞*/ ,
      "AU" /*Australia, Commonwealth of澳大利亞聯邦*/ ,
      "SB" /*Solomon Islands所羅門群島*/ ,
      "CK" /*Cook Islands庫克群島*/ ,
      "FJ" /*Fiji, Republic of the Fiji Islands斐濟*/ ,
      "PF" /*French Polynesia法屬波利尼西亞*/ ,
      "KI" /*Kiribati, Republic of基里巴斯共和國*/ ,
      "GU" /*Guam關島*/ ,
      "NR" /*Nauru, Republic of瑙魯*/ ,
      "NC" /*New Caledonia新喀裡多尼亞*/ ,
      "VU" /*Vanuatu, Republic of瓦努阿圖共和國*/ ,
      "NZ" /*New Zealand新西蘭*/ ,
      "NU" /*Niue紐埃*/ ,
      "NF" /*Norfolk Island諾福克島*/ ,
      "MP" /*Northern Mariana Islands, Commonwealth of the北馬里亞納群島,英聯邦*/ ,
      "UM" /*United States Minor Outlying Islands美國本土外小島嶼*/ ,
      "FM" /*Micronesia, Federated States of密克羅尼西亞聯邦*/ ,
      "MH" /*Marshall Islands, Republic of the馬紹爾群島共和國*/ ,
      "PW" /*Palau, Republic of帕勞共和國*/ ,
      "PG" /*Papua New Guinea, Independent State of巴布亞新幾內亞獨立國*/ ,
      "PN" /*Pitcairn Islands皮特凱恩群島*/ ,
      "TK" /*Tokelau托克勞*/ ,
      "TO" /*Tonga, Kingdom of湯加王國*/ ,
      "TV" /*Tuvalu圖瓦盧*/ ,
      "WF" /*Wallis and Futuna瓦利斯群島和富圖納群島*/ ,
      "WS" /*Samoa, Independent State of薩摩亞獨立國*/)
      ),array( 'name' => 'South America','iso_code_2' => array(
      "AR" /*Argentina, Argentine Republic阿根廷*/ ,
      "BO" /*Bolivia, Republic of玻利維亞共和國*/ ,
      "BR" /*Brazil, Federative Republic of巴西聯邦共和國*/ ,
      "CL" /*Chile, Republic of智利共和國*/ ,
      "CO" /*Colombia, Republic of哥倫比亞共和國*/ ,
      "EC" /*Ecuador, Republic of厄瓜多爾共和國*/ ,
      "FK" /*Falkland Islands (Malvinas)福克蘭群島(馬爾維納斯)*/ ,
      "GF" /*French Guiana法屬圭亞那*/ ,
      "GY" /*Guyana, Co-operative Republic of圭亞那合作共和國*/ ,
      "PY" /*Paraguay, Republic of巴拉圭共和國*/ ,
      "PE" /*Peru, Republic of秘魯共和國*/ ,
      "SR" /*Suriname, Republic of蘇里南共和國*/ ,
      "UY" /*Uruguay, Eastern Republic of烏拉圭東岸共和國*/ ,
      "VE" /*Venezuela, Bolivarian Republic of委內瑞拉玻利瓦爾共和國*/ )
      ),array( 'name' => 'Africa','iso_code_2' => array(
      "DZ" /*Algeria, People's Democratic Republic of阿爾及利亞人民民主共和國*/ ,
      "AO" /*Angola, Republic of安哥拉共和國*/ ,
      "BW" /*Botswana, Republic of博茨瓦納共和國*/ ,
      "BI" /*Burundi, Republic of布隆迪共和國*/ ,
      "CM" /*Cameroon, Republic of喀麥隆共和國*/ ,
      "CV" /*Cape Verde, Republic of佛得角共和國*/ ,
      "CF" /*Central African Republic中非共和國*/ ,
      "TD" /*Chad, Republic of乍得共和國*/ ,
      "KM" /*Comoros, Union of the科摩羅聯盟*/ ,
      "YT" /*Mayotte馬約特島*/ ,
      "CG" /*Congo, Republic of the剛果共和國*/ ,
      "CD" /*Congo, Democratic Republic of the剛果民主共和國*/ ,
      "BJ" /*Benin, Republic of貝寧共和國*/ ,
      "GQ" /*Equatorial Guinea, Republic of赤道幾內亞共和國*/ ,
      "ET" /*Ethiopia, Federal Democratic Republic of埃塞俄比亞聯邦民主共和國*/ ,
      "ER" /*Eritrea, State of厄立特里亞國家*/ ,
      "DJ" /*Djibouti, Republic of吉布提共和國*/ ,
      "GA" /*Gabon, Gabonese Republic加蓬*/ ,
      "GM" /*Gambia, Republic of the岡比亞共和國*/ ,
      "GH" /*Ghana, Republic of加納共和國*/ ,
      "GN" /*Guinea, Republic of幾內亞共和國*/ ,
      "CI" /*Cote d'Ivoire, Republic of科特迪瓦共和國*/ ,
      "KE" /*Kenya, Republic of肯尼亞共和國*/ ,
      "LS" /*Lesotho, Kingdom of萊索托王國*/ ,
      "LR" /*Liberia, Republic of利比里亞共和國*/ ,
      "LY" /*Libyan Arab Jamahiriya阿拉伯利比亞民眾國*/ ,
      "MG" /*Madagascar, Republic of馬達加斯加共和國*/ ,
      "MW" /*Malawi, Republic of馬拉維共和國*/ ,
      "ML" /*Mali, Republic of馬里共和國*/ ,
      "MR" /*Mauritania, Islamic Republic of毛里塔尼亞伊斯蘭共和國*/ ,
      "MU" /*Mauritius, Republic of毛里求斯共和國*/ ,
      "MA" /*Morocco, Kingdom of摩洛哥王國*/ ,
      "MZ" /*Mozambique, Republic of莫桑比克共和國*/ ,
      "NA" /*Namibia, Republic of納米比亞共和國*/ ,
      "NE" /*Niger, Republic of尼日爾共和國*/ ,
      "NG" /*Nigeria, Federal Republic of尼日利亞聯邦共和國*/ ,
      "GW" /*Guinea-Bissau, Republic of幾內亞比紹共和國*/ ,
      "RE" /*Reunion留尼旺島*/ ,
      "RW" /*Rwanda, Republic of盧旺達共和國*/ ,
      "SH" /*Saint Helena聖赫勒拿*/ ,
      "ST" /*Sao Tome and Principe, Democratic Republic of聖多美與普林西比民主共和國*/ ,
      "SN" /*Senegal, Republic of塞內加爾共和國*/ ,
      "SC" /*Seychelles, Republic of塞舌爾共和國*/ ,
      "SL" /*Sierra Leone, Republic of塞拉利昂共和國*/ ,
      "SO" /*Somalia, Somali Republic索馬里*/ ,
      "ZA" /*South Africa, Republic of南非共和國*/ ,
      "ZW" /*Zimbabwe, Republic of津巴布韋共和國*/ ,
      "SS" /*South Sudan南蘇丹*/ ,
      "EH" /*Western Sahara西撒哈拉*/ ,
      "SD" /*Sudan, Republic of蘇丹共和國*/ ,
      "SZ" /*Swaziland, Kingdom of斯威士蘭王國*/ ,
      "TG" /*Togo, Togolese Republic多哥*/ ,
      "TN" /*Tunisia, Tunisian Republic突尼斯*/ ,
      "UG" /*Uganda, Republic of烏干達共和國*/ ,
      "EG" /*Egypt, Arab Republic of埃及*/ ,
      "TZ" /*Tanzania, United Republic of坦桑尼亞聯合共和國*/ ,
      "BF" /*Burkina Faso布基納法索*/ ,
      "ZM" /*Zambia, Republic of贊比亞共和國*/)
      ),array( 'name' => 'Antarctica','iso_code_2' => array(
      "AQ" /*Antarctica (the territory South of 60 deg S)南極洲*/ ,
      "BV" /*Bouvet Island (Bouvetoya)布維島*/ ,
      "GS" /*South Georgia and the South Sandwich Islands南喬治亞島和南桑威奇群島*/ ,
      "TF" /*French Southern Territories法國南部領土*/ ,
      "HM" /*Heard Island and McDonald Islands赫德島和麥當勞群島*/ )
     )
    );
      ?>
      <?php foreach ($countries_sort_by_continent as $continent_name) {  ?>
      <optgroup label="<?php echo $continent_name['name']; ?>">
      <?php foreach ($countries as $country) { 
      if (in_array($country['iso_code_2'],$continent_name['iso_code_2'])) { ?>
      <option value="<?php echo $country['country_id']; ?>"<?php if ($country['country_id'] == $country_id) { ?> selected="selected"<?php } ?>
      style="background: url('image/flags/<?php echo strtolower($country['iso_code_2']); ?>.png') center right no-repeat;">
    <?php echo $country['name']; ?></option>
      <?php } } ?>
      </optgroup>
      <?php } ?>
      <option value="236">Other Area</option>
    

示範:

有一點要注意,世界七大洲的地理劃分沒有統一的定義,而且有些國家的領土橫跨超過一個洲,所以有些國家會在列表重複出現,但這不影響Opencart儲存地址資料。

我的網店只服務特定地區。
我怎樣一次過隱藏不需要的國家?

剛才的程式碼中,每行變數值旁都標示了國家或特殊政區的名字。
如果你的網店不服務某個國家,就將標示該國家名字的一行刪除。
如果你的網店只服務某些大洲,就將其他洲的變數值刪除掉。
這樣你就不用在Opencart後台逐一修改國家的設定來停用它們。


<p>
&#60;!--<br />
Make sure that you have properly installed Opencart vQmod.<br />
Copy this page of script.<br />
Save as a .xml file of utf-8 encoding without BOM into the directory [vqmod/xml].<br />
Name the file as you like.<br />
--&gt;</p>
<pre>
&lt;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&gt;
&lt;modification&gt;
 &lt;id&gt;List of Countries by continents&lt;/id&gt;
 &lt;version&gt;2.0.0&lt;/version&gt;
 &lt;author&gt;Flexidigi Solution Ltd.&lt;/author&gt;
 &lt;file name=&#34;catalog/view/theme/default/template/account/register.tpl&#34;&gt;</pre>
<pre id="repeat_content">
    &lt;operation error=&#34;skip&#34;&gt;
      &lt;search position=&#34;replace&#34;&gt;&lt;![CDATA[&lt;?php foreach ($countries as $country) { ?&gt;]]&gt;&lt;/search&gt;
      &lt;add&gt;&lt;![CDATA[ &lt;!--
    &lt;?php $countries_sort_by_continent=array(
array( &#39;name&#39; =&gt; &#39;Asia&#39;,&#39;iso_code_2&#39; =&gt; array(&#34;AF&#34; /*Afghanistan, Islamic Republic of阿富汗伊斯蘭共和國*/ ,
&#34;AZ&#34; /*Azerbaijan, Republic of阿塞拜疆共和國*/ ,
&#34;BH&#34; /*Bahrain, Kingdom of巴林王國*/ ,
&#34;BD&#34; /*Bangladesh, People&#39;s Republic of孟加拉國*/ ,
&#34;AM&#34; /*Armenia, Republic of亞美尼亞共和國*/ ,
&#34;BT&#34; /*Bhutan, Kingdom of不丹王國*/ ,
&#34;IO&#34; /*British Indian Ocean Territory (Chagos Archipelago)英屬印度洋領地(查戈斯群島)*/ ,
&#34;BN&#34; /*Brunei Darussalam汶萊*/ ,
&#34;MM&#34; /*Myanmar, Union of緬甸聯盟*/ ,
&#34;KH&#34; /*Cambodia, Kingdom of柬埔寨王國*/ ,
&#34;LK&#34; /*Sri Lanka, Democratic Socialist Republic of斯里蘭卡民主社會主義共和國*/ ,
&#34;CN&#34; /*China, People&#39;s Republic of中華人民共和國*/ ,
&#34;TW&#34; /*Taiwan台灣*/ ,
&#34;CX&#34; /*Christmas Island聖誕島*/ ,
&#34;CC&#34; /*Cocos (Keeling) Islands科科斯(基林)群島*/ ,
&#34;CY&#34; /*Cyprus, Republic of塞浦路斯共和國*/ ,
&#34;GE&#34; /*Georgia格魯吉亞*/ ,
&#34;PS&#34; /*Palestinian Territory, Occupied被佔巴勒斯坦領土*/ ,
&#34;HK&#34; /*Hong Kong 香港*/ ,
&#34;IN&#34; /*India, Republic of印度共和國*/ ,
&#34;ID&#34; /*Indonesia, Republic of印度尼西亞共和國*/ ,
&#34;IR&#34; /*Iran, Islamic Republic of伊朗伊斯蘭共和國*/ ,
&#34;IQ&#34; /*Iraq, Republic of伊拉克共和國*/ ,
&#34;IL&#34; /*Israel, State of以色列*/ ,
&#34;JP&#34; /*Japan日本*/ ,
&#34;KZ&#34; /*Kazakhstan, Republic of哈薩克斯坦共和國*/ ,
&#34;JO&#34; /*Jordan, Hashemite Kingdom of約旦哈希姆王國*/ ,
&#34;KP&#34; /*Korea, Democratic People&#39;s Republic of朝鮮民主主義人民共和國*/ ,
&#34;KR&#34; /*Korea, Republic of大韓民國*/ ,
&#34;KW&#34; /*Kuwait, State of科威特國家*/ ,
&#34;KG&#34; /*Kyrgyz Republic吉爾吉斯共和國*/ ,
&#34;LA&#34; /*Lao People&#39;s Democratic Republic老撾人民民主共和國*/ ,
&#34;LB&#34; /*Lebanon, Lebanese Republic黎巴嫩*/ ,
&#34;MO&#34; /*Macao 澳門*/ ,
&#34;MY&#34; /*Malaysia馬來西亞*/ ,
&#34;MV&#34; /*Maldives, Republic of馬爾代夫共和國*/ ,
&#34;MN&#34; /*Mongolia蒙古*/ ,
&#34;OM&#34; /*Oman, Sultanate of阿曼蘇丹國*/ ,
&#34;NP&#34; /*Nepal, State of尼泊爾國家*/ ,
&#34;PK&#34; /*Pakistan, Islamic Republic of巴基斯坦伊斯蘭共和國*/ ,
&#34;PH&#34; /*Philippines, Republic of the菲律賓共和國*/ ,
&#34;TL&#34; /*Timor-Leste, Democratic Republic of東帝汶民主共和國*/ ,
&#34;QA&#34; /*Qatar, State of卡塔爾*/ ,
&#34;RU&#34; /*Russian Federation俄羅斯聯邦*/ ,
&#34;SA&#34; /*Saudi Arabia, Kingdom of沙特阿拉伯王國*/ ,
&#34;SG&#34; /*Singapore, Republic of新加坡*/ ,
&#34;VN&#34; /*Vietnam, Socialist Republic of越南社會主義共和國*/ ,
&#34;SY&#34; /*Syrian Arab Republic阿拉伯敘利亞共和國*/ ,
&#34;TJ&#34; /*Tajikistan, Republic of塔吉克斯坦共和國*/ ,
&#34;TH&#34; /*Thailand, Kingdom of 泰國*/ ,
&#34;AE&#34; /*United Arab Emirates阿拉伯聯合酋長國*/ ,
&#34;TR&#34; /*Turkey, Republic of土耳其共和國*/ ,
&#34;TM&#34; /*Turkmenistan土庫曼斯坦*/ ,
&#34;UZ&#34; /*Uzbekistan, Republic of烏茲別克斯坦共和國*/ ,
&#34;YE&#34; /*Yemen也門*/)),
array( &#39;name&#39; =&gt; &#39;Europe&#39;,&#39;iso_code_2&#39; =&gt; array(&#34;AL&#34; /*Albania, Republic of阿爾巴尼亞共和國*/ ,
&#34;AD&#34; /*Andorra, Principality of安道​​爾公國的*/ ,
&#34;AZ&#34; /*Azerbaijan, Republic of阿塞拜疆共和國*/ ,
&#34;AT&#34; /*Austria, Republic of奧地利共和國*/ ,
&#34;AM&#34; /*Armenia, Republic of亞美尼亞共和國*/ ,
&#34;BE&#34; /*Belgium, Kingdom of比利時王國*/ ,
&#34;BA&#34; /*Bosnia and Herzegovina波斯尼亞和黑塞哥維那*/ ,
&#34;BG&#34; /*Bulgaria, Republic of保加利亞共和國*/ ,
&#34;BY&#34; /*Belarus, Republic of白俄羅斯共和國*/ ,
&#34;HR&#34; /*Croatia, Republic of克羅地亞*/ ,
&#34;CY&#34; /*Cyprus, Republic of塞浦路斯共和國*/ ,
&#34;CZ&#34; /*Czech Republic捷克共和國*/ ,
&#34;DK&#34; /*Denmark, Kingdom of丹麥王國*/ ,
&#34;EE&#34; /*Estonia, Republic of愛沙尼亞共和國*/ ,
&#34;FO&#34; /*Faroe Islands法羅群島*/ ,
&#34;FI&#34; /*Finland, Republic of芬蘭共和國*/ ,
&#34;AX&#34; /*Åland Islands奧蘭群島*/ ,
&#34;FR&#34; /*France, French Republic法國*/ ,
&#34;GE&#34; /*Georgia格魯吉亞*/ ,
&#34;DE&#34; /*Germany, Federal Republic of德意志聯邦共和國*/ ,
&#34;GI&#34; /*Gibraltar直布羅陀*/ ,
&#34;GR&#34; /*Greece, Hellenic Republic希臘*/ ,
&#34;VA&#34; /*Holy See (Vatican City State)羅馬教廷(梵蒂岡城國)*/ ,
&#34;HU&#34; /*Hungary, Republic of匈牙利共和國*/ ,
&#34;IS&#34; /*Iceland, Republic of冰島共和國*/ ,
&#34;IE&#34; /*Ireland愛爾蘭*/ ,
&#34;IT&#34; /*Italy, Italian Republic意大利*/ ,
&#34;KZ&#34; /*Kazakhstan, Republic of哈薩克斯坦共和國*/ ,
&#34;LV&#34; /*Latvia, Republic of拉脫維亞共和國*/ ,
&#34;LI&#34; /*Liechtenstein, Principality of列支敦士登公國的*/ ,
&#34;LT&#34; /*Lithuania, Republic of立陶宛共和國*/ ,
&#34;LU&#34; /*Luxembourg, Grand Duchy of盧森堡大公國*/ ,
&#34;MT&#34; /*Malta, Republic of馬耳他共和國*/ ,
&#34;MC&#34; /*Monaco, Principality of摩納哥公國的*/ ,
&#34;MD&#34; /*Moldova, Republic of摩爾多瓦共和國*/ ,
&#34;ME&#34; /*Montenegro, Republic of黑山共和國*/ ,
&#34;NL&#34; /*Netherlands, Kingdom of the荷蘭王國*/ ,
&#34;NO&#34; /*Norway, Kingdom of挪威王國*/ ,
&#34;PL&#34; /*Poland, Republic of波蘭共和國*/ ,
&#34;PT&#34; /*Portugal, Portuguese Republic葡萄牙*/ ,
&#34;RO&#34; /*Romania羅馬尼亞*/ ,
&#34;RU&#34; /*Russian Federation俄羅斯聯邦*/ ,
&#34;SM&#34; /*San Marino, Republic of聖馬力諾共和國*/ ,
&#34;RS&#34; /*Serbia, Republic of塞爾維亞共和國*/ ,
&#34;SK&#34; /*Slovakia (Slovak Republic)斯洛伐克(斯洛伐克共和國)*/ ,
&#34;SI&#34; /*Slovenia, Republic of斯洛文尼亞共和國*/ ,
&#34;ES&#34; /*Spain, Kingdom of西班牙王國*/ ,
&#34;SJ&#34; /*Svalbard , Jan Mayen Islands斯瓦爾巴群島和揚馬​​延島*/ ,
&#34;SE&#34; /*Sweden, Kingdom of瑞典王國*/ ,
&#34;CH&#34; /*Switzerland, Swiss Confederation瑞士*/ ,
&#34;TR&#34; /*Turkey, Republic of土耳其共和國*/ ,
&#34;UA&#34; /*Ukraine烏克蘭*/ ,
&#34;MK&#34; /*Macedonia, Republic of馬其頓共和國*/ ,
&#34;GB&#34; /*United Kingdom of Great Britain , Northern Ireland大不列顛及北愛爾蘭聯合王國*/ ,
&#34;GG&#34; /*Guernsey, Bailiwick of根西島*/ ,
&#34;JE&#34; /*Jersey, Bailiwick of 澤西島*/ ,
&#34;IM&#34; /*Isle of Man馬恩島*/)),
array( &#39;name&#39; =&gt; &#39;North America&#39;,&#39;iso_code_2&#39; =&gt; array(&#34;AG&#34; /*Antigua and Barbuda安提瓜和巴布達*/ ,
&#34;BS&#34; /*Bahamas, Commonwealth of the巴哈馬,英聯邦*/ ,
&#34;BB&#34; /*Barbados巴巴多斯*/ ,
&#34;BM&#34; /*Bermuda百慕大*/ ,
&#34;BZ&#34; /*Belize伯利茲*/ ,
&#34;VG&#34; /*British Virgin Islands英屬維爾京群島*/ ,
&#34;CA&#34; /*Canada加拿大*/ ,
&#34;KY&#34; /*Cayman Islands開曼群島*/ ,
&#34;CR&#34; /*Costa Rica, Republic of哥斯達黎加共和國*/ ,
&#34;CU&#34; /*Cuba, Republic of古巴共和國*/ ,
&#34;DM&#34; /*Dominica, Commonwealth of多米尼加聯邦*/ ,
&#34;DO&#34; /*Dominican Republic多米尼加共和國*/ ,
&#34;SV&#34; /*El Salvador, Republic of薩爾瓦多共和國*/ ,
&#34;GL&#34; /*Greenland格陵蘭*/ ,
&#34;GD&#34; /*Grenada格林納達*/ ,
&#34;GP&#34; /*Guadeloupe瓜德羅普島*/ ,
&#34;GT&#34; /*Guatemala, Republic of危地馬拉共和國*/ ,
&#34;HT&#34; /*Haiti, Republic of海地共和國*/ ,
&#34;HN&#34; /*Honduras, Republic of洪都拉斯共和國*/ ,
&#34;JM&#34; /*Jamaica牙買加*/ ,
&#34;MQ&#34; /*Martinique馬提尼克島*/ ,
&#34;MX&#34; /*Mexico, United Mexican States墨西哥*/ ,
&#34;MS&#34; /*Montserrat蒙特塞拉特*/ ,
&#34;AN&#34; /*Netherlands Antilles荷屬安的列斯*/ ,
&#34;CW&#34; /*Curaçao庫拉索島*/ ,
&#34;AW&#34; /*Aruba阿魯巴*/ ,
&#34;SX&#34; /*Sint Maarten (Netherlands)聖馬丁島(荷蘭)*/ ,
&#34;BQ&#34; /*Bonaire, Sint Eustatius and Saba博內爾島*/ ,
&#34;NI&#34; /*Nicaragua, Republic of尼加拉瓜共和國*/ ,
&#34;UM&#34; /*United States Minor Outlying Islands美國本土外小島嶼*/ ,
&#34;PA&#34; /*Panama, Republic of巴拿馬共和國*/ ,
&#34;PR&#34; /*Puerto Rico, Commonwealth of波多黎各聯邦*/ ,
&#34;BL&#34; /*Saint Barthelemy聖巴泰勒米*/ ,
&#34;KN&#34; /*Saint Kitts and Nevis, Federation of聖基茨和尼維斯聯邦*/ ,
&#34;AI&#34; /*Anguilla安圭拉*/ ,
&#34;LC&#34; /*Saint Lucia聖盧西亞*/ ,
&#34;MF&#34; /*Saint Martin聖馬丁*/ ,
&#34;PM&#34; /*Saint Pierre and Miquelon聖皮埃爾和密克隆*/ ,
&#34;VC&#34; /*Saint Vincent and the Grenadines聖文森特和格林納丁斯*/ ,
&#34;TT&#34; /*Trinidad and Tobago, Republic of特里尼達和多巴哥共和國*/ ,
&#34;TC&#34; /*Turks and Caicos Islands特克斯和凱科斯群島*/ ,
&#34;US&#34; /*United States of America美國美國*/ ,
&#34;VI&#34; /*United States Virgin Islands美屬維爾京群島*/)),
array( &#39;name&#39; =&gt; &#39;Oceania&#39;,&#39;iso_code_2&#39; =&gt; array(&#34;AS&#34; /*American Samoa美屬薩摩亞*/ ,
&#34;AU&#34; /*Australia, Commonwealth of澳大利亞聯邦*/ ,
&#34;SB&#34; /*Solomon Islands所羅門群島*/ ,
&#34;CK&#34; /*Cook Islands庫克群島*/ ,
&#34;FJ&#34; /*Fiji, Republic of the Fiji Islands斐濟*/ ,
&#34;PF&#34; /*French Polynesia法屬波利尼西亞*/ ,
&#34;KI&#34; /*Kiribati, Republic of基里巴斯共和國*/ ,
&#34;GU&#34; /*Guam關島*/ ,
&#34;NR&#34; /*Nauru, Republic of瑙魯*/ ,
&#34;NC&#34; /*New Caledonia新喀裡多尼亞*/ ,
&#34;VU&#34; /*Vanuatu, Republic of瓦努阿圖共和國*/ ,
&#34;NZ&#34; /*New Zealand新西蘭*/ ,
&#34;NU&#34; /*Niue紐埃*/ ,
&#34;NF&#34; /*Norfolk Island諾福克島*/ ,
&#34;MP&#34; /*Northern Mariana Islands, Commonwealth of the北馬里亞納群島,英聯邦*/ ,
&#34;UM&#34; /*United States Minor Outlying Islands美國本土外小島嶼*/ ,
&#34;FM&#34; /*Micronesia, Federated States of密克羅尼西亞聯邦*/ ,
&#34;MH&#34; /*Marshall Islands, Republic of the馬紹爾群島共和國*/ ,
&#34;PW&#34; /*Palau, Republic of帕勞共和國*/ ,
&#34;PG&#34; /*Papua New Guinea, Independent State of巴布亞新幾內亞獨立國*/ ,
&#34;PN&#34; /*Pitcairn Islands皮特凱恩群島*/ ,
&#34;TK&#34; /*Tokelau托克勞*/ ,
&#34;TO&#34; /*Tonga, Kingdom of湯加王國*/ ,
&#34;TV&#34; /*Tuvalu圖瓦盧*/ ,
&#34;WF&#34; /*Wallis and Futuna瓦利斯群島和富圖納群島*/ ,
&#34;WS&#34; /*Samoa, Independent State of薩摩亞獨立國*/)),
array( &#39;name&#39; =&gt; &#39;South America&#39;,&#39;iso_code_2&#39; =&gt; array(&#34;AR&#34; /*Argentina, Argentine Republic阿根廷*/ ,
&#34;BO&#34; /*Bolivia, Republic of玻利維亞共和國*/ ,
&#34;BR&#34; /*Brazil, Federative Republic of巴西聯邦共和國*/ ,
&#34;CL&#34; /*Chile, Republic of智利共和國*/ ,
&#34;CO&#34; /*Colombia, Republic of哥倫比亞共和國*/ ,
&#34;EC&#34; /*Ecuador, Republic of厄瓜多爾共和國*/ ,
&#34;FK&#34; /*Falkland Islands (Malvinas)福克蘭群島(馬爾維納斯)*/ ,
&#34;GF&#34; /*French Guiana法屬圭亞那*/ ,
&#34;GY&#34; /*Guyana, Co-operative Republic of圭亞那合作共和國*/ ,
&#34;PY&#34; /*Paraguay, Republic of巴拉圭共和國*/ ,
&#34;PE&#34; /*Peru, Republic of秘魯共和國*/ ,
&#34;SR&#34; /*Suriname, Republic of蘇里南共和國*/ ,
&#34;UY&#34; /*Uruguay, Eastern Republic of烏拉圭東岸共和國*/ ,
&#34;VE&#34; /*Venezuela, Bolivarian Republic of委內瑞拉玻利瓦爾共和國*/ )),
array( &#39;name&#39; =&gt; &#39;Africa&#39;,&#39;iso_code_2&#39; =&gt; array(
&#34;DZ&#34; /*Algeria, People&#39;s Democratic Republic of阿爾及利亞人民民主共和國*/ ,
&#34;AO&#34; /*Angola, Republic of安哥拉共和國*/ ,
&#34;BW&#34; /*Botswana, Republic of博茨瓦納共和國*/ ,
&#34;BI&#34; /*Burundi, Republic of布隆迪共和國*/ ,
&#34;CM&#34; /*Cameroon, Republic of喀麥隆共和國*/ ,
&#34;CV&#34; /*Cape Verde, Republic of佛得角共和國*/ ,
&#34;CF&#34; /*Central African Republic中非共和國*/ ,
&#34;TD&#34; /*Chad, Republic of乍得共和國*/ ,
&#34;KM&#34; /*Comoros, Union of the科摩羅聯盟*/ ,
&#34;YT&#34; /*Mayotte馬約特島*/ ,
&#34;CG&#34; /*Congo, Republic of the剛果共和國*/ ,
&#34;CD&#34; /*Congo, Democratic Republic of the剛果民主共和國*/ ,
&#34;BJ&#34; /*Benin, Republic of貝寧共和國*/ ,
&#34;GQ&#34; /*Equatorial Guinea, Republic of赤道幾內亞共和國*/ ,
&#34;ET&#34; /*Ethiopia, Federal Democratic Republic of埃塞俄比亞聯邦民主共和國*/ ,
&#34;ER&#34; /*Eritrea, State of厄立特里亞國家*/ ,
&#34;DJ&#34; /*Djibouti, Republic of吉布提共和國*/ ,
&#34;GA&#34; /*Gabon, Gabonese Republic加蓬*/ ,
&#34;GM&#34; /*Gambia, Republic of the岡比亞共和國*/ ,
&#34;GH&#34; /*Ghana, Republic of加納共和國*/ ,
&#34;GN&#34; /*Guinea, Republic of幾內亞共和國*/ ,
&#34;CI&#34; /*Cote d&#39;Ivoire, Republic of科特迪瓦共和國*/ ,
&#34;KE&#34; /*Kenya, Republic of肯尼亞共和國*/ ,
&#34;LS&#34; /*Lesotho, Kingdom of萊索托王國*/ ,
&#34;LR&#34; /*Liberia, Republic of利比里亞共和國*/ ,
&#34;LY&#34; /*Libyan Arab Jamahiriya阿拉伯利比亞民眾國*/ ,
&#34;MG&#34; /*Madagascar, Republic of馬達加斯加共和國*/ ,
&#34;MW&#34; /*Malawi, Republic of馬拉維共和國*/ ,
&#34;ML&#34; /*Mali, Republic of馬里共和國*/ ,
&#34;MR&#34; /*Mauritania, Islamic Republic of毛里塔尼亞伊斯蘭共和國*/ ,
&#34;MU&#34; /*Mauritius, Republic of毛里求斯共和國*/ ,
&#34;MA&#34; /*Morocco, Kingdom of摩洛哥王國*/ ,
&#34;MZ&#34; /*Mozambique, Republic of莫桑比克共和國*/ ,
&#34;NA&#34; /*Namibia, Republic of納米比亞共和國*/ ,
&#34;NE&#34; /*Niger, Republic of尼日爾共和國*/ ,
&#34;NG&#34; /*Nigeria, Federal Republic of尼日利亞聯邦共和國*/ ,
&#34;GW&#34; /*Guinea-Bissau, Republic of幾內亞比紹共和國*/ ,
&#34;RE&#34; /*Reunion留尼旺島*/ ,
&#34;RW&#34; /*Rwanda, Republic of盧旺達共和國*/ ,
&#34;SH&#34; /*Saint Helena聖赫勒拿*/ ,
&#34;ST&#34; /*Sao Tome and Principe, Democratic Republic of聖多美與普林西比民主共和國*/ ,
&#34;SN&#34; /*Senegal, Republic of塞內加爾共和國*/ ,
&#34;SC&#34; /*Seychelles, Republic of塞舌爾共和國*/ ,
&#34;SL&#34; /*Sierra Leone, Republic of塞拉利昂共和國*/ ,
&#34;SO&#34; /*Somalia, Somali Republic索馬里*/ ,
&#34;ZA&#34; /*South Africa, Republic of南非共和國*/ ,
&#34;ZW&#34; /*Zimbabwe, Republic of津巴布韋共和國*/ ,
&#34;SS&#34; /*South Sudan南蘇丹*/ ,
&#34;EH&#34; /*Western Sahara西撒哈拉*/ ,
&#34;SD&#34; /*Sudan, Republic of蘇丹共和國*/ ,
&#34;SZ&#34; /*Swaziland, Kingdom of斯威士蘭王國*/ ,
&#34;TG&#34; /*Togo, Togolese Republic多哥*/ ,
&#34;TN&#34; /*Tunisia, Tunisian Republic突尼斯*/ ,
&#34;UG&#34; /*Uganda, Republic of烏干達共和國*/ ,
&#34;EG&#34; /*Egypt, Arab Republic of埃及*/ ,
&#34;TZ&#34; /*Tanzania, United Republic of坦桑尼亞聯合共和國*/ ,
&#34;BF&#34; /*Burkina Faso布基納法索*/ ,
&#34;ZM&#34; /*Zambia, Republic of贊比亞共和國*/)),
array( &#39;name&#39; =&gt; &#39;Antarctica&#39;,&#39;iso_code_2&#39; =&gt; array(
&#34;AQ&#34; /*Antarctica (the territory South of 60 deg S)南極洲*/ ,
&#34;BV&#34; /*Bouvet Island (Bouvetoya)布維島*/ ,
&#34;GS&#34; /*South Georgia and the South Sandwich Islands南喬治亞島和南桑威奇群島*/ ,
&#34;TF&#34; /*French Southern Territories法國南部領土*/ ,
&#34;HM&#34; /*Heard Island and McDonald Islands赫德島和麥當勞群島*/ )));
?&gt;
--&gt;
              &lt;?php foreach ($countries_sort_by_continent as $continent_name) {  ?&gt;
          &lt;optgroup label=&#34;&lt;?php echo $continent_name[&#39;name&#39;]; ?&gt;&#34;&gt;
          &lt;?php foreach ($countries as $country) { 
          if (in_array($country[&#39;iso_code_2&#39;],$continent_name[&#39;iso_code_2&#39;])) { ?&gt;
              &lt;option value=&#34;&lt;?php echo $country[&#39;country_id&#39;]; ?&gt;&#34;&lt;?php if ($country[&#39;country_id&#39;] == $country_id) { ?&gt; selected=&#34;selected&#34;&lt;?php } ?&gt;
              style=&#34;background: url(&#39;image/flags/&lt;?php echo strtolower($country[&#39;iso_code_2&#39;]); ?&gt;.png&#39;) center right no-repeat;&#34;&gt;&lt;?php echo $country[&#39;name&#39;]; ?&gt;&lt;/option&gt;
              &lt;?php } } ?&gt;
              &lt;/optgroup&gt;
              &lt;?php } ?&gt;
       &lt;option value=&#34;236&#34;&gt;Other Area&lt;/option&gt;
       &lt;?php if (false) { ?&gt;]]&gt;&lt;/add&gt;
  &lt;/operation&gt;
 &lt;/file&gt;
</pre>
<script type="text/javascript">
 var FilePaths = new Array(8)
FilePaths[0] = "catalog/view/theme/default/template/account/address_form.tpl";
FilePaths[1] = "catalog/view/theme/default/template/affiliate/edit.tpl";
FilePaths[2] = "catalog/view/theme/default/template/affiliate/register.tpl";
FilePaths[3] = "catalog/view/theme/default/template/checkout/address.tpl";
FilePaths[4] = "catalog/view/theme/default/template/checkout/guest.tpl";
FilePaths[5] = "catalog/view/theme/default/template/checkout/guest_shipping.tpl";
FilePaths[6] = "catalog/view/theme/default/template/checkout/register.tpl ";
FilePaths[7] = "catalog/view/theme/default/template/total/shipping.tpl";
document.write('<pre>');
      for ( var i = 0; i < FilePaths.length; i++) {
document.write(" &#60;file name=&#34;");
document.write(FilePaths[i]);
document.writeln("&#34;&#62;");
document.writeln(document.getElementById('repeat_content').innerHTML);
      }
document.writeln('</pre>');
</script>
<pre>
&lt;/modification&gt;
</pre>

小國旗
在國家選擇列,每國名字旁都有一支小國旗,是不是很讚呢?

修改程式方法:

  1. 分別編輯以下檔案:
    • [catalog/view/theme/default/template/account/address_form.tpl]
    • [catalog/view/theme/default/template/account/register.tpl]
    • [catalog/view/theme/default/template/affiliate/edit.tpl]
    • [catalog/view/theme/default/template/affiliate/register.tpl]
    • [catalog/view/theme/default/template/checkout/address.tpl]
    • [catalog/view/theme/default/template/checkout/guest.tpl]
    • [catalog/view/theme/default/template/checkout/guest_shipping.tpl]
    • [catalog/view/theme/default/template/checkout/register.tpl ]
    • [catalog/view/theme/default/template/total/shipping.tpl]
  2. 搜索以下程式碼:
                  <?php foreach ($countries as $country) { ?>
                  <?php if ($country['country_id'] == $country_id) { ?>
                  <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
  3. 將以上程式碼替換為以下程式碼:
    <?php foreach ($countries as $country) { ?>
     <option value="<?php echo $country['country_id']; ?>" 
     <?php if ($country['country_id'] == $country_id) { ?>selected="selected"<?php } ?> 
      style="background: url('image/flags/<?php echo strtolower($country['iso_code_2']); ?>.png') center right no-repeat;"><?php echo $country['name']; ?></option>
    <?php } ?>

以上方法適用於Opencart v1.5.1.3

每個國家旁邊都有一支小國旗,十分酷啊!
但這效果只有Firefox能夠展示,真是可惜!

因為目前Google Chrome和Internet Explorer都不支援<option>有背景圖片。



今次真係冇叉用!

Opencart儘管有英文以外的語言包下載,但國家和地區名字仍以英文顯示。
怎樣把Opencart的英文國家和地區名字轉為中文?

雖然英文是國際語言,一般人都可以基本理解,但未必人人都記得自己的英文地址。
服務稱心的網店應該照顧到使用不同語言的客戶,雖然不必要譒譯所有國家的名字,但最基本要譒譯網店生意涵蓋地區的名字。

笨實的方法是登入Opencart後台,到“System”→“Localisation”→“Zones”&“Country”逐一編輯各國、各地區的名字。
但你既然來到「多嚿魚教室」,就不用做這些Macau Friend的事,教你一次過修改國家和地區名字!

Finding Solution

批量修改國家和地區名字的方法就是用phpMyAdmin修改儲存在MySQL Database的國家和地區名字。

修改MySQL Database之前,請備份Opencart的數據庫,以便你日後還原。
備份方法:

  1. 登入phpMyAdmin,進入Opencart所在的database。
  2. 按右頁的“匯出”標籤。
  3. 揀選“SQL”為格式,然後按「自訂 - 顯示所有可用的選項」。
  4. 在「資料表」一欄揀選“Zones”和“Country”。
  5. 揀選「儲存爲檔案」,揀選「CREATE TABLE 選項」的「IF NOT EXISTS」。
  6. ,並儲存.sql檔案。

備份完成後,就正式開始修改MySQL Database的資料。
修改MySQL Database步驟:

  1. 登入phpMyAdmin,進入Opencart所在的database。
  2. 複製以下的SQL script。
    REPLACE INTO `country` VALUES ('242', 'Republic of South Sudan', 'SS', 'SSD', '', '0', '1');
    REPLACE INTO `country` VALUES ('241', 'Republic of Serbia', 'RS', 'SRB', '', '0', '1');
    REPLACE INTO `country` VALUES ('240', 'Montenegro', 'ME', 'MNE', '', '0', '1');
    REPLACE INTO `country` VALUES ('206', '台灣', 'TW', 'TWN', '', '0', '1');
    REPLACE INTO `country` VALUES ('125', '中國澳門(Macau, China)', 'MO', 'MAC', '', '0', '1');
    REPLACE INTO `country` VALUES ('107', '日本国', 'JP', 'JPN', '', '0', '1');
    REPLACE INTO `country` VALUES ('96', '中國香港(Hong Kong, China)', 'HK', 'HKG', '', '0', '1');
    REPLACE INTO `country` VALUES ('44', '中华人民共和国', 'CN', 'CHN', '', '0', '1');
    REPLACE INTO `zone` VALUES ('684', '44', 'AN', '安徽省', '1');
    REPLACE INTO `zone` VALUES ('685', '44', 'BE', '北京市', '1');
    REPLACE INTO `zone` VALUES ('686', '44', 'CH', '重庆市', '1');
    REPLACE INTO `zone` VALUES ('687', '44', 'FU', '福建省', '1');
    REPLACE INTO `zone` VALUES ('688', '44', 'GA', '甘肃省', '1');
    REPLACE INTO `zone` VALUES ('689', '44', 'GU', '广东省', '1');
    REPLACE INTO `zone` VALUES ('690', '44', 'GX', '广西壮族自治区', '1');
    REPLACE INTO `zone` VALUES ('691', '44', 'GZ', '贵州省', '1');
    REPLACE INTO `zone` VALUES ('692', '44', 'HA', '海南省', '1');
    REPLACE INTO `zone` VALUES ('693', '44', 'HB', '河北省', '1');
    REPLACE INTO `zone` VALUES ('694', '44', 'HL', '黑龙江省', '1');
    REPLACE INTO `zone` VALUES ('695', '44', 'HE', '河南省', '1');
    REPLACE INTO `zone` VALUES ('696', '44', 'HK', '香港', '0');
    REPLACE INTO `zone` VALUES ('697', '44', 'HU', '湖北省', '1');
    REPLACE INTO `zone` VALUES ('698', '44', 'HN', '湖南省', '1');
    REPLACE INTO `zone` VALUES ('699', '44', 'IM', '内蒙古自治区', '1');
    REPLACE INTO `zone` VALUES ('700', '44', 'JI', '江苏省', '1');
    REPLACE INTO `zone` VALUES ('701', '44', 'JX', '江西省', '1');
    REPLACE INTO `zone` VALUES ('702', '44', 'JL', '吉林省', '1');
    REPLACE INTO `zone` VALUES ('703', '44', 'LI', '辽宁省', '1');
    REPLACE INTO `zone` VALUES ('704', '44', 'MA', '澳门', '0');
    REPLACE INTO `zone` VALUES ('705', '44', 'NI', '宁夏回族自治区', '1');
    REPLACE INTO `zone` VALUES ('706', '44', 'SH', '陕西省', '1');
    REPLACE INTO `zone` VALUES ('707', '44', 'SA', '山东省', '1');
    REPLACE INTO `zone` VALUES ('708', '44', 'SG', '上海市', '1');
    REPLACE INTO `zone` VALUES ('709', '44', 'SX', '山西省', '1');
    REPLACE INTO `zone` VALUES ('710', '44', 'SI', '四川省', '1');
    REPLACE INTO `zone` VALUES ('711', '44', 'TI', '天津市', '1');
    REPLACE INTO `zone` VALUES ('712', '44', 'XI', '新疆维吾尔自治区', '1');
    REPLACE INTO `zone` VALUES ('713', '44', 'YU', '云南省', '1');
    REPLACE INTO `zone` VALUES ('714', '44', 'ZH', '浙江省', '1');
    REPLACE INTO `zone` VALUES ('1410', '96', 'HCW', '港島中西區(Central and Western, Hong Kong Island)', '1');
    REPLACE INTO `zone` VALUES ('1411', '96', 'HEA', '港島東區(Eastern, Hong Kong Island)', '1');
    REPLACE INTO `zone` VALUES ('1412', '96', 'HSO', '港島南區(Southern, Hong Kong Island)', '1');
    REPLACE INTO `zone` VALUES ('1413', '96', 'HWC', '港島灣仔區(Wan Chai, Hong Kong Island)', '1');
    REPLACE INTO `zone` VALUES ('1414', '96', 'KKC', '九龍九龍城區(Kowloon City, Kowloon)', '1');
    REPLACE INTO `zone` VALUES ('1415', '96', 'KKT', '九龍觀塘區(Kwun Tong, Kowloon)', '1');
    REPLACE INTO `zone` VALUES ('1416', '96', 'KSS', '九龍深水埗區(Sham Shui Po, Kowloon)', '1');
    REPLACE INTO `zone` VALUES ('1417', '96', 'KWT', '九龍黃大仙區(Wong Tai Sin, Kowloon)', '1');
    REPLACE INTO `zone` VALUES ('1418', '96', 'KYT', '九龍油尖旺區(Yau Tsim Mong, Kowloon)', '1');
    REPLACE INTO `zone` VALUES ('1419', '96', 'NIS', '新界離島區(Islands, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1420', '96', 'NKT', '新界葵青區(Kwai Tsing, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1421', '96', 'NNO', '新界北區(North, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1422', '96', 'NSK', '新界西貢區(Sai Kung, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1423', '96', 'NST', '新界沙田區(Sha Tin, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1424', '96', 'NTP', '新界大埔區(Tai Po, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1425', '96', 'NTW', '新界荃灣區(Tsuen Wan, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1426', '96', 'NTM', '新界屯門區(Tuen Mun, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1427', '96', 'NYL', '新界元朗區(Yuen Long, New Territories)', '1');
    REPLACE INTO `zone` VALUES ('1657', '107', 'AI', '愛知県', '1');
    REPLACE INTO `zone` VALUES ('1658', '107', 'AK', '秋田県', '1');
    REPLACE INTO `zone` VALUES ('1659', '107', 'AO', '青森県', '1');
    REPLACE INTO `zone` VALUES ('1660', '107', 'CH', '千葉県', '1');
    REPLACE INTO `zone` VALUES ('1661', '107', 'EH', '愛媛県', '1');
    REPLACE INTO `zone` VALUES ('1662', '107', 'FK', '福井県', '1');
    REPLACE INTO `zone` VALUES ('1663', '107', 'FU', '福岡県', '1');
    REPLACE INTO `zone` VALUES ('1664', '107', 'FS', '福島県', '1');
    REPLACE INTO `zone` VALUES ('1665', '107', 'GI', '岐阜県', '1');
    REPLACE INTO `zone` VALUES ('1666', '107', 'GU', '群馬県', '1');
    REPLACE INTO `zone` VALUES ('1667', '107', 'HI', '広島県', '1');
    REPLACE INTO `zone` VALUES ('1668', '107', 'HO', '北海道', '1');
    REPLACE INTO `zone` VALUES ('1669', '107', 'HY', '兵庫県', '1');
    REPLACE INTO `zone` VALUES ('1670', '107', 'IB', '茨城県', '1');
    REPLACE INTO `zone` VALUES ('1671', '107', 'IS', '石川県', '1');
    REPLACE INTO `zone` VALUES ('1672', '107', 'IW', '岩手県', '1');
    REPLACE INTO `zone` VALUES ('1673', '107', 'KA', '香川県', '1');
    REPLACE INTO `zone` VALUES ('1674', '107', 'KG', '鹿児島県', '1');
    REPLACE INTO `zone` VALUES ('1675', '107', 'KN', '神奈川県', '1');
    REPLACE INTO `zone` VALUES ('1676', '107', 'KO', '高知県', '1');
    REPLACE INTO `zone` VALUES ('1677', '107', 'KU', '熊本県', '1');
    REPLACE INTO `zone` VALUES ('1678', '107', 'KY', '京都府', '1');
    REPLACE INTO `zone` VALUES ('1679', '107', 'MI', '三重県', '1');
    REPLACE INTO `zone` VALUES ('1680', '107', 'MY', '宮城県', '1');
    REPLACE INTO `zone` VALUES ('1681', '107', 'MZ', '宮崎県', '1');
    REPLACE INTO `zone` VALUES ('1682', '107', 'NA', '長野県', '1');
    REPLACE INTO `zone` VALUES ('1683', '107', 'NG', '長崎県', '1');
    REPLACE INTO `zone` VALUES ('1684', '107', 'NR', '奈良県', '1');
    REPLACE INTO `zone` VALUES ('1685', '107', 'NI', '新潟県', '1');
    REPLACE INTO `zone` VALUES ('1686', '107', 'OI', '大分県', '1');
    REPLACE INTO `zone` VALUES ('1687', '107', 'OK', '岡山県', '1');
    REPLACE INTO `zone` VALUES ('1688', '107', 'ON', '沖縄県', '1');
    REPLACE INTO `zone` VALUES ('1689', '107', 'OS', '大阪府', '1');
    REPLACE INTO `zone` VALUES ('1690', '107', 'SA', '佐賀県', '1');
    REPLACE INTO `zone` VALUES ('1691', '107', 'SI', '埼玉県', '1');
    REPLACE INTO `zone` VALUES ('1692', '107', 'SH', '滋賀県', '1');
    REPLACE INTO `zone` VALUES ('1693', '107', 'SM', '島根県', '1');
    REPLACE INTO `zone` VALUES ('1694', '107', 'SZ', '静岡県', '1');
    REPLACE INTO `zone` VALUES ('1695', '107', 'TO', '栃木県', '1');
    REPLACE INTO `zone` VALUES ('1696', '107', 'TS', '徳島県', '1');
    REPLACE INTO `zone` VALUES ('1697', '107', 'TK', '東京都', '1');
    REPLACE INTO `zone` VALUES ('1698', '107', 'TT', '鳥取県', '1');
    REPLACE INTO `zone` VALUES ('1699', '107', 'TY', '富山県', '1');
    REPLACE INTO `zone` VALUES ('1700', '107', 'WA', '和歌山県', '1');
    REPLACE INTO `zone` VALUES ('1701', '107', 'YA', '山形県', '1');
    REPLACE INTO `zone` VALUES ('1702', '107', 'YM', '山口県', '1');
    REPLACE INTO `zone` VALUES ('1703', '107', 'YN', '山梨県', '1');
    REPLACE INTO `zone` VALUES ('1933', '125', 'OLF', '澳門半島花地瑪堂區(Our Lady of Fatima Parish)', '1');
    REPLACE INTO `zone` VALUES ('1934', '125', 'ANT', '澳門半島聖安多尼堂區(St. Anthony Parish)', '1');
    REPLACE INTO `zone` VALUES ('1935', '125', 'LAZ', '澳門半島望德堂區(St. Lazarus Parish)', '1');
    REPLACE INTO `zone` VALUES ('1936', '125', 'CAT', '澳門半島大堂區(Cathedral Parish)', '1');
    REPLACE INTO `zone` VALUES ('1937', '125', 'LAW', '澳門半島風順堂區(St. Lawrence Parish)', '1');
    REPLACE INTO `zone` VALUES ('3135', '206', 'TW-CHA', '彰化縣', '1');
    REPLACE INTO `zone` VALUES ('3136', '206', 'TW-CYQ', '嘉義縣', '1');
    REPLACE INTO `zone` VALUES ('3137', '206', 'TW-HSZ', '新竹市', '1');
    REPLACE INTO `zone` VALUES ('3138', '206', 'TW-HUA', '花蓮縣', '1');
    REPLACE INTO `zone` VALUES ('3139', '206', 'TW-ILA', '宜蘭縣', '1');
    REPLACE INTO `zone` VALUES ('3140', '206', 'KH', 'Kao-hsiung county', '0');
    REPLACE INTO `zone` VALUES ('3141', '206', 'KM', '金門縣', '1');
    REPLACE INTO `zone` VALUES ('3142', '206', 'LC', '連江縣', '1');
    REPLACE INTO `zone` VALUES ('3143', '206', 'TW-MIA', '苗栗縣', '1');
    REPLACE INTO `zone` VALUES ('3144', '206', 'TW-NAN', '南投縣', '1');
    REPLACE INTO `zone` VALUES ('3145', '206', 'TW-PEN', '澎湖縣', '1');
    REPLACE INTO `zone` VALUES ('3146', '206', 'TW-PIF', '屏東縣', '1');
    REPLACE INTO `zone` VALUES ('3147', '206', 'TG', 'T\'ai-chung', '0');
    REPLACE INTO `zone` VALUES ('3148', '206', 'TW-TNN', '台南市', '1');
    REPLACE INTO `zone` VALUES ('3149', '206', 'TW-TPQ', '新北市', '1');
    REPLACE INTO `zone` VALUES ('3150', '206', 'TW-TTT', '台東縣', '1');
    REPLACE INTO `zone` VALUES ('3151', '206', 'TW-TAO', '桃園縣', '1');
    REPLACE INTO `zone` VALUES ('3152', '206', 'TW-YUN', '雲林縣', '1');
    REPLACE INTO `zone` VALUES ('3153', '206', 'TW-CYI', '嘉義市', '1');
    REPLACE INTO `zone` VALUES ('3154', '206', 'TW-KEE', '基隆市', '1');
    REPLACE INTO `zone` VALUES ('3155', '206', 'TW-HSQ', '新竹縣', '1');
    REPLACE INTO `zone` VALUES ('3156', '206', 'TW-TXG', '台中市', '1');
    REPLACE INTO `zone` VALUES ('3157', '206', 'TN', 'T\'ai-nan', '0');
    REPLACE INTO `zone` VALUES ('3158', '206', 'TW-KHH', '高雄市', '1');
    REPLACE INTO `zone` VALUES ('3159', '206', 'TW-TPE', '台北市', '1');
    REPLACE INTO `zone` VALUES ('3970', '44', 'QH', '青海省', '1');
    REPLACE INTO `zone` VALUES ('3971', '44', 'TB', '西藏自治區', '1');
    REPLACE INTO `zone` VALUES ('3972', '125', 'TP', '氹仔(Taipa)', '1');
    REPLACE INTO `zone` VALUES ('3973', '125', 'CO', '路環(Coloane)', '1');
    REPLACE INTO `zone` VALUES ('3974', '125', 'CT', '路氹城(Cotai)', '1');
    REPLACE INTO `zone` VALUES ('3975', '240', 'ME-01', 'Andrijevica', '1');
    REPLACE INTO `zone` VALUES ('3976', '240', 'ME-02', 'Bar', '1');
    REPLACE INTO `zone` VALUES ('3977', '240', 'ME-03', 'Berane', '1');
    REPLACE INTO `zone` VALUES ('3978', '240', 'ME-04', 'Bijelo Polje', '1');
    REPLACE INTO `zone` VALUES ('3979', '240', 'ME-05', 'Budva', '1');
    REPLACE INTO `zone` VALUES ('3980', '240', 'ME-06', 'Cetinje', '1');
    REPLACE INTO `zone` VALUES ('3981', '240', 'ME-07', 'Danilovgrad', '1');
    REPLACE INTO `zone` VALUES ('3982', '240', 'ME-08', 'Herceg-Novi', '1');
    REPLACE INTO `zone` VALUES ('3983', '240', 'ME-09', 'Kolašin', '1');
    REPLACE INTO `zone` VALUES ('3984', '240', 'ME-10', 'Kotor', '1');
    REPLACE INTO `zone` VALUES ('3985', '240', 'ME-11', 'Mojkovac', '1');
    REPLACE INTO `zone` VALUES ('3986', '240', 'ME-12', 'Nikšić', '1');
    REPLACE INTO `zone` VALUES ('3987', '240', 'ME-13', 'Plav', '1');
    REPLACE INTO `zone` VALUES ('3988', '240', 'ME-14', 'Pljevlja', '1');
    REPLACE INTO `zone` VALUES ('3989', '240', 'ME-15', 'Plužine', '1');
    REPLACE INTO `zone` VALUES ('3990', '240', 'ME-16', 'Podgorica', '1');
    REPLACE INTO `zone` VALUES ('3991', '240', 'ME-17', 'Rožaje', '1');
    REPLACE INTO `zone` VALUES ('3992', '240', 'ME-18', 'Šavnik', '1');
    REPLACE INTO `zone` VALUES ('3993', '240', 'ME-19', 'Tivat', '1');
    REPLACE INTO `zone` VALUES ('3994', '240', 'ME-20', 'Ulcinj', '1');
    REPLACE INTO `zone` VALUES ('3995', '240', 'ME-21', 'Žabljak', '1');
    REPLACE INTO `zone` VALUES ('3998', '241', 'RS-00', 'Beograd', '1');
    REPLACE INTO `zone` VALUES ('3999', '241', 'RS-14', 'Borski okrug', '1');
    REPLACE INTO `zone` VALUES ('4000', '241', 'RS-11', 'Braničevski okrug', '1');
    REPLACE INTO `zone` VALUES ('4001', '241', 'RS-23', 'Jablanički okrug', '1');
    REPLACE INTO `zone` VALUES ('4002', '241', 'RS-06', 'Južnobački okrug', '1');
    REPLACE INTO `zone` VALUES ('4003', '241', 'RS-04', 'Južnobanatski okrug', '1');
    REPLACE INTO `zone` VALUES ('4004', '241', 'RS-09', 'Kolubarski okrug', '1');
    REPLACE INTO `zone` VALUES ('4005', '241', 'RS-25', 'Kosovski okrug', '1');
    REPLACE INTO `zone` VALUES ('4006', '241', 'RS-28', 'Kosovsko-Mitrovački okrug', '1');
    REPLACE INTO `zone` VALUES ('4007', '241', 'RS-29', 'Kosovsko-Pomoravski okrug', '1');
    REPLACE INTO `zone` VALUES ('4008', '241', 'RS-08', 'Mačvanski okrug', '1');
    REPLACE INTO `zone` VALUES ('4009', '241', 'RS-17', 'Moravički okrug', '1');
    REPLACE INTO `zone` VALUES ('4010', '241', 'RS-20', 'Nišavski okrug', '1');
    REPLACE INTO `zone` VALUES ('4011', '241', 'RS-24', 'Pčinjski okrug', '1');
    REPLACE INTO `zone` VALUES ('4012', '241', 'RS-26', 'Pećki okrug', '1');
    REPLACE INTO `zone` VALUES ('4013', '241', 'RS-22', 'Pirotski okrug', '1');
    REPLACE INTO `zone` VALUES ('4014', '241', 'RS-10', 'Podunavski okrug', '1');
    REPLACE INTO `zone` VALUES ('4015', '241', 'RS-13', 'Pomoravski okrug', '1');
    REPLACE INTO `zone` VALUES ('4016', '241', 'RS-27', 'Prizrenski okrug', '1');
    REPLACE INTO `zone` VALUES ('4017', '241', 'RS-19', 'Rasinski okrug', '1');
    REPLACE INTO `zone` VALUES ('4018', '241', 'RS-18', 'Raški okrug', '1');
    REPLACE INTO `zone` VALUES ('4019', '241', 'RS-01', 'Severnobački okrug', '1');
    REPLACE INTO `zone` VALUES ('4020', '241', 'RS-03', 'Severnobanatski okrug', '1');
    REPLACE INTO `zone` VALUES ('4021', '241', 'RS-02', 'Srednjebanatski okrug', '1');
    REPLACE INTO `zone` VALUES ('4022', '241', 'RS-07', 'Sremski okrug', '1');
    REPLACE INTO `zone` VALUES ('4023', '241', 'RS-12', 'Šumadijski okrug', '1');
    REPLACE INTO `zone` VALUES ('4024', '241', 'RS-21', 'Toplički okrug', '1');
    REPLACE INTO `zone` VALUES ('4025', '241', 'RS-15', 'Zaječarski okrug', '1');
    REPLACE INTO `zone` VALUES ('4026', '241', 'RS-05', 'Zapadnobački okrug', '1');
    REPLACE INTO `zone` VALUES ('4027', '241', 'RS-16', 'Zlatiborski okrug', '1');
    REPLACE INTO `zone` VALUES ('4028', '242', 'SS-EC', 'Central Equatoria', '1');
    REPLACE INTO `zone` VALUES ('4029', '242', 'SS-EE', 'Eastern Equatoria', '1');
    REPLACE INTO `zone` VALUES ('4030', '242', 'SS-JG', 'Jonglei', '1');
    REPLACE INTO `zone` VALUES ('4031', '242', 'SS-LK', 'Lakes', '1');
    REPLACE INTO `zone` VALUES ('4032', '242', 'SS-BN', 'Northern Bahr el-Ghazal', '1');
    REPLACE INTO `zone` VALUES ('4033', '242', 'SS-UY', 'Unity', '1');
    REPLACE INTO `zone` VALUES ('4034', '242', 'SS-NU', 'Upper Nile', '1');
    REPLACE INTO `zone` VALUES ('4035', '242', 'SS-WR', 'Warrap', '1');
    REPLACE INTO `zone` VALUES ('4036', '242', 'SS-BW', 'Western Bahr el-Ghazal', '1');
    REPLACE INTO `zone` VALUES ('4037', '242', 'SS-EW', 'Western Equatoria', '1');
    
  3. 按右頁的“SQL”標籤。
  4. 在SQL查詢欄貼上SQL script,然後按
  5. 登入Opencart後台,到“System”→“Localisation”→“Zones”,隨便“Edit”一個地區,不用改任何字,按
    (這一步的目的是讓Opencart對在phpMyAdmin的資料修改起反應)。
  6. 在“Zones”和“Country”版面,到最後一頁(因為漢字國家名字排最後),檢查一下地區名稱,如無意外應該是漢字。
  7. 瀏覽網店前台的會員註冊表格,國家和地區選擇欄已經更新。
以上方法適用於Opencart v1.5.1.3
你有叉用?
剛才的SQL script發揮甚麼功效呢?
一下子就改妥國家和地區名。

Opencart的database有兩個表用來儲存地方資料——“Country”儲存了國家和特殊政區的資料,“Zones”儲存了各國行政區域的資料。

SQL script針對這兩個表作以下修改:
“Country”

  • 新增3個國家——“Republic of South Sudan”“Republic of Serbia”“Montenegro”
  • 翻譯使用漢字的國家/特殊政區名稱——將“China”、“Hong Kong”、“Macau”、“Taiwan”、“Japan”分別改為「中华人民共和国」、「中國香港(Hong Kong, China)」、「中國澳門(Macau, China)」、「台灣」、「日本国」。

“Zones”
  • 台灣行政區域的英文名稱譒譯成正體中文;
    “T'ai-pei county”更新為「新北市」;
    停用台中縣高雄縣台南縣的選項(這些行政區在2010年已經廢止);
    將各區的地區代碼(Zone Code)轉為ISO 3166-2
  • 中国行政区域的英文名称翻译成简体中文;
    新增原Opencart遗漏了的「青海省」和「西藏自治区」;
    停用“Hong Kong”和“Macau”的选项,因为它们是特殊政区,已经在“Country”出现。
  • 香港行政區域的英文名字改成中英並列。
  • 澳門行政區域的英文名字改成中英並列;
    新增「氹仔(Taipa)」、「路環(Coloane)」、「路氹城(Cotai)」原Opencart遺漏的區域。


  • 日本行政區域的英文名稱譒譯成日文(漢字)


  • 新增黑山的21個地區。


  • 新增塞爾維亞的30個地區。


  • 新增南蘇丹的10個地區。


國家和地區的資料源自《維基百科》。

世界政局波譎雲詭,隨時有新政區新國家成立。所以最好在國家選擇欄新增一個「其他地方」供客戶揀選。