Laravel/Configure countries regions states

From Aimeos documentation

Laravel
Other languages:
English 100%


Countries

If you want to ship your products to several countries or you need to know from which countries your customers are, you have to enable the country selection in the address page of the checkout process.

By default, the country list is hidden for the billing and delivery address in the checkout process. To make show them and make them mandatory you need to add "order.base.address.countryid" to the list of values defined in

In the Aimeos package this is configured for billing and delivery addresses in the config/shop.php configuration file:

  1. 'client' => array(
  2.     'html' => array(
  3.         'checkout' => array(
  4.             'standard' => array(
  5.                 'address' => array(
  6.                     'billing' => array(
  7.                         'mandatory' => array(
  8.                             'order.base.address.salutation',
  9.                             'order.base.address.firstname',
  10.                             'order.base.address.lastname',
  11.                             'order.base.address.address1',
  12.                             'order.base.address.postal',
  13.                             'order.base.address.city',
  14.                             'order.base.address.languageid',
  15.                             'order.base.address.email',
  16.                             'order.base.address.countryid',
  17.                         ),
  18.                     ),
  19.                     'delivery' => array(
  20.                         'mandatory' => array(
  21.                             'order.base.address.salutation',
  22.                             'order.base.address.firstname',
  23.                             'order.base.address.lastname',
  24.                             'order.base.address.address1',
  25.                             'order.base.address.postal',
  26.                             'order.base.address.city',
  27.                             'order.base.address.languageid',
  28.                             'order.base.address.email',
  29.                             'order.base.address.countryid',
  30.                         ),
  31.                     ),
  32.                 ),
  33.             ),
  34.         ),
  35.     ),
  36. ),

If no selection should be enforced, you can use instead

To make the country for billing and delivery addresses optional, use this configuration:

  1. 'client' => array(
  2.     'html' => array(
  3.         'checkout' => array(
  4.             'standard' => array(
  5.                 'address' => array(
  6.                     'billing' => array(
  7.                         'optional' => array(
  8.                             // ... other optional fields ...
  9.                             'order.base.address.countryid',
  10.                         ),
  11.                     ),
  12.                     'delivery' => array(
  13.                         'optional' => array(
  14.                             // ... other optional fields ...
  15.                             'order.base.address.countryid',
  16.                         ),
  17.                     ),
  18.                 ),
  19.             ),
  20.         ),
  21.     ),
  22. ),

The list of countries is defined by the values added to the configuration key client/html/checkout/standard/address/countries. The configuration below will add all countries worldwide to the select boxes for the billing and delivery address:

  1. 'client' => array(
  2.     'html' => array(
  3.         'checkout' => array(
  4.             'standard' => array(
  5.                 'address' => array(
  6.                     'countries' => array(
  7.                         'AD', // Andorra
  8.                         'AE', // United Arab Emirates
  9.                         'AF', // Afghanistan
  10.                         'AG', // Antigua and Barbuda
  11.                         'AI', // Anguilla
  12.                         'AL', // Albania
  13.                         'AM', // Armenia
  14.                         'AO', // Angola
  15.                         'AQ', // Antarctica
  16.                         'AR', // Argentina
  17.                         'AS', // American Samoa
  18.                         'AT', // Austria
  19.                         'AU', // Australia
  20.                         'AW', // Aruba
  21.                         'AX', // Åland Islands
  22.                         'AZ', // Azerbaijan
  23.                         'BA', // Bosnia and Herzegovina
  24.                         'BB', // Barbados
  25.                         'BD', // Bangladesh
  26.                         'BE', // Belgium
  27.                         'BF', // Burkina Faso
  28.                         'BG', // Bulgaria
  29.                         'BH', // Bahrain
  30.                         'BI', // Burundi
  31.                         'BJ', // Benin
  32.                         'BL', // Saint Barthélemy
  33.                         'BM', // Bermuda
  34.                         'BN', // Brunei Darussalam
  35.                         'BO', // Bolivia, Plurinational State of
  36.                         'BQ', // Bonaire, Sint Eustatius and Saba
  37.                         'BR', // Brazil
  38.                         'BS', // Bahamas
  39.                         'BT', // Bhutan
  40.                         'BV', // Bouvet Island
  41.                         'BW', // Botswana
  42.                         'BY', // Belarus
  43.                         'BZ', // Belize
  44.                         'CA', // Canada
  45.                         'CC', // Cocos (Keeling) Islands
  46.                         'CD', // Congo, the Democratic Republic of the
  47.                         'CF', // Central African Republic
  48.                         'CG', // Congo
  49.                         'CH', // Switzerland
  50.                         'CI', // Côte d'Ivoire
  51.                         'CK', // Cook Islands
  52.                         'CL', // Chile
  53.                         'CM', // Cameroon
  54.                         'CN', // China
  55.                         'CO', // Colombia
  56.                         'CR', // Costa Rica
  57.                         'CU', // Cuba
  58.                         'CV', // Cape Verde
  59.                         'CW', // Curaçao
  60.                         'CX', // Christmas Island
  61.                         'CY', // Cyprus
  62.                         'CZ', // Czech Republic
  63.                         'DE', // Germany
  64.                         'DJ', // Djibouti
  65.                         'DK', // Denmark
  66.                         'DM', // Dominica
  67.                         'DO', // Dominican Republic
  68.                         'DZ', // Algeria
  69.                         'EC', // Ecuador
  70.                         'EE', // Estonia
  71.                         'EG', // Egypt
  72.                         'EH', // Western Sahara
  73.                         'ER', // Eritrea
  74.                         'ES', // Spain
  75.                         'ET', // Ethiopia
  76.                         'FI', // Finland
  77.                         'FJ', // Fiji
  78.                         'FK', // Falkland Islands (Malvinas)
  79.                         'FM', // Micronesia, Federated States of
  80.                         'FO', // Faroe Islands
  81.                         'FR', // France
  82.                         'GA', // Gabon
  83.                         'GB', // United Kingdom
  84.                         'GD', // Grenada
  85.                         'GE', // Georgia
  86.                         'GF', // French Guiana
  87.                         'GG', // Guernsey
  88.                         'GH', // Ghana
  89.                         'GI', // Gibraltar
  90.                         'GL', // Greenland
  91.                         'GM', // Gambia
  92.                         'GN', // Guinea
  93.                         'GP', // Guadeloupe
  94.                         'GQ', // Equatorial Guinea
  95.                         'GR', // Greece
  96.                         'GS', // South Georgia and the South Sandwich Islands
  97.                         'GT', // Guatemala
  98.                         'GU', // Guam
  99.                         'GW', // Guinea-Bissau
  100.                         'GY', // Guyana
  101.                         'HK', // Hong Kong
  102.                         'HM', // Heard Island and McDonald Islands
  103.                         'HN', // Honduras
  104.                         'HR', // Croatia
  105.                         'HT', // Haiti
  106.                         'HU', // Hungary
  107.                         'ID', // Indonesia
  108.                         'IE', // Ireland
  109.                         'IL', // Israel
  110.                         'IM', // Isle of Man
  111.                         'IN', // India
  112.                         'IO', // British Indian Ocean Territory
  113.                         'IQ', // Iraq
  114.                         'IR', // Iran, Islamic Republic of
  115.                         'IS', // Iceland
  116.                         'IT', // Italy
  117.                         'JE', // Jersey
  118.                         'JM', // Jamaica
  119.                         'JO', // Jordan
  120.                         'JP', // Japan
  121.                         'KE', // Kenya
  122.                         'KG', // Kyrgyzstan
  123.                         'KH', // Cambodia
  124.                         'KI', // Kiribati
  125.                         'KM', // Comoros
  126.                         'KN', // Saint Kitts and Nevis
  127.                         'KP', // Korea, Democratic People's Republic of
  128.                         'KR', // Korea, Republic of
  129.                         'KW', // Kuwait
  130.                         'KY', // Cayman Islands
  131.                         'KZ', // Kazakhstan
  132.                         'LA', // Lao People's Democratic Republic
  133.                         'LB', // Lebanon
  134.                         'LC', // Saint Lucia
  135.                         'LI', // Liechtenstein
  136.                         'LK', // Sri Lanka
  137.                         'LR', // Liberia
  138.                         'LS', // Lesotho
  139.                         'LT', // Lithuania
  140.                         'LU', // Luxembourg
  141.                         'LV', // Latvia
  142.                         'LY', // Libya
  143.                         'MA', // Morocco
  144.                         'MC', // Monaco
  145.                         'MD', // Moldova, Republic of
  146.                         'ME', // Montenegro
  147.                         'MF', // Saint Martin (French part)
  148.                         'MG', // Madagascar
  149.                         'MH', // Marshall Islands
  150.                         'MK', // Macedonia
  151.                         'ML', // Mali
  152.                         'MM', // Myanmar
  153.                         'MN', // Mongolia
  154.                         'MO', // Macao
  155.                         'MP', // Northern Mariana Islands
  156.                         'MQ', // Martinique
  157.                         'MR', // Mauritania
  158.                         'MS', // Montserrat
  159.                         'MT', // Malta
  160.                         'MU', // Mauritius
  161.                         'MV', // Maldives
  162.                         'MW', // Malawi
  163.                         'MX', // Mexico
  164.                         'MY', // Malaysia
  165.                         'MZ', // Mozambique
  166.                         'NA', // Namibia
  167.                         'NC', // New Caledonia
  168.                         'NE', // Niger
  169.                         'NF', // Norfolk Island
  170.                         'NG', // Nigeria
  171.                         'NI', // Nicaragua
  172.                         'NL', // Netherlands
  173.                         'NO', // Norway
  174.                         'NP', // Nepal
  175.                         'NR', // Nauru
  176.                         'NU', // Niue
  177.                         'NZ', // New Zealand
  178.                         'OM', // Oman
  179.                         'PA', // Panama
  180.                         'PE', // Peru
  181.                         'PF', // French Polynesia
  182.                         'PG', // Papua New Guinea
  183.                         'PH', // Philippines
  184.                         'PK', // Pakistan
  185.                         'PL', // Poland
  186.                         'PM', // Saint Pierre and Miquelon
  187.                         'PN', // Pitcairn
  188.                         'PR', // Puerto Rico
  189.                         'PS', // Palestine, State of
  190.                         'PT', // Portugal
  191.                         'PW', // Palau
  192.                         'PY', // Paraguay
  193.                         'QA', // Qatar
  194.                         'RE', // Réunion
  195.                         'RO', // Romania
  196.                         'RS', // Serbia
  197.                         'RU', // Russian Federation
  198.                         'RW', // Rwanda
  199.                         'SA', // Saudi Arabia
  200.                         'SB', // Solomon Islands
  201.                         'SC', // Seychelles
  202.                         'SD', // Sudan
  203.                         'SE', // Sweden
  204.                         'SG', // Singapore
  205.                         'SH', // Saint Helena, Ascension and Tristan da Cunha
  206.                         'SI', // Slovenia
  207.                         'SJ', // Svalbard and Jan Mayen
  208.                         'SK', // Slovakia
  209.                         'SL', // Sierra Leone
  210.                         'SM', // San Marino
  211.                         'SN', // Senegal
  212.                         'SO', // Somalia
  213.                         'SR', // Suriname
  214.                         'SS', // South Sudan
  215.                         'ST', // Sao Tome and Principe
  216.                         'SV', // El Salvador
  217.                         'SX', // Sint Maarten (Dutch part)
  218.                         'SY', // Syrian Arab Republic
  219.                         'SZ', // Swaziland
  220.                         'TC', // Turks and Caicos Islands
  221.                         'TD', // Chad
  222.                         'TF', // French Southern Territories
  223.                         'TG', // Togo
  224.                         'TH', // Thailand
  225.                         'TJ', // Tajikistan
  226.                         'TK', // Tokelau
  227.                         'TL', // Timor-Leste
  228.                         'TM', // Turkmenistan
  229.                         'TN', // Tunisia
  230.                         'TO', // Tonga
  231.                         'TR', // Turkey
  232.                         'TT', // Trinidad and Tobago
  233.                         'TV', // Tuvalu
  234.                         'TW', // Taiwan
  235.                         'TZ', // Tanzania, United Republic of
  236.                         'UA', // Ukraine
  237.                         'UG', // Uganda
  238.                         'UM', // United States Minor Outlying Islands
  239.                         'US', // United States
  240.                         'UY', // Uruguay
  241.                         'UZ', // Uzbekistan
  242.                         'VA', // Vatican City State (Holy See)
  243.                         'VC', // Saint Vincent and the Grenadines
  244.                         'VE', // Venezuela, Bolivarian Republic of
  245.                         'VG', // Virgin Islands, British
  246.                         'VI', // Virgin Islands, U.S.
  247.                         'VN', // Viet Nam
  248.                         'VU', // Vanuatu
  249.                         'WF', // Wallis and Futuna
  250.                         'WS', // Samoa
  251.                         'YE', // Yemen
  252.                         'YT', // Mayotte
  253.                         'ZA', // South Africa
  254.                         'ZM', // Zambia
  255.                         'ZW', // Zimbabwe
  256.                     ),
  257.                 ),
  258.             ),
  259.         ),
  260.     ),
  261. ),

States and Regions

For each country you can freely define a list of states or regions that can be used afterwards to calculate the final price for each delivery option.

To define states or regions via the configuration use something like this:

  1. 'client' => array(
  2.     'html' => array(
  3.         'checkout' => array(
  4.             'standard' => array(
  5.                 'address' => array(
  6.                     'states' => array(
  7.                         'US' => array(
  8.                             'CA' => 'California',
  9.                             'NY' => 'New York',
  10.                             // ...
  11.                         'EU' => array(
  12.                             'W' => 'Western Europe',
  13.                             'C' => 'Central Europe',
  14.                             // ...
  15.                         ),
  16.                     ),
  17.                 ),
  18.             ),
  19.         ),
  20.     ),
  21. ),

The key you have chosen for the state or region will be stored in the order address of the customer and can then be used during the rest of the checkout process. More details can be found in the documentation of the configuration option: