CIF files.

Posts: 88
Joined: 11/06/2007
Bug FinderGetting busy with the Ubercode.

I just added several .cif files I've created and thought I'd post links to them all here.

All the address formats are generic as I do not know the proper formatting for each of these countries. If someone else knows, feel free to share.

Posts: 1968
Joined: 08/07/2007
AdministratoreLiTe!

It looks like most of them have an SQL error in the INSERT into {uc_zones}. There shouldn't be a comma after the final set of values, methinks.

Also, countries that don't use zones shouldn't even have any in the zones table or their address format.

Posts: 88
Joined: 11/06/2007
Bug FinderGetting busy with the Ubercode.

Ahh, thanks for pointing that out. They should all be fixed now.

Posts: 1968
Joined: 08/07/2007
AdministratoreLiTe!

Awesome, I'll get them added in.

Posts: 67
Joined: 01/23/2008

Lyle wrote:
Also, countries that don't use zones shouldn't even have any in the zones table or their address format.

Some countries do not have zones. But have list of cities. I need to list them with a combobox like the zone field in checkout page. According to this field, we will calculate the shipping. And for that this field must have fix values for coding. Currently the city field on checkout page is just free textbox. Is there any approach to import and list cities as combobox or should i start from scratch.

Posts: 4116
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

You'll have to write a custom module to handle the city listing. My recommendation is to use hook_form_alter() in a custom module to change the textfield into a select box with the options being whatever cities you want to list.

Posts: 67
Joined: 01/23/2008

Thanks Ryan,
So for display purpose i will try the hook_form_alter(). One more thing. Should i create a uc_city table in database and import the city list like the zone list using the country.cif file ? What is your suggesstion about that ?

Posts: 4116
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Yeah, I'd create a city table and then match those up by country ID (that's what it sounded like you needed, but match it by zone ID if you need that instead). I'm not sure if it's worth bothering with mimicking the whole .cif system or not... you could honestly just have a form with a textarea that an admin can enter city names in and have them added to the DB when the form gets submitted.

Posts: 67
Joined: 01/23/2008

Lyle wrote:
Awesome, I'll get them added in.

Please find attached cif file.

AttachmentSize
turkey_792_1.cif1.38 KB
Posts: 23
Joined: 03/13/2008

bakyildiz,
I was wondering if you have the cities implemented and if you could share how you made it happen, I need this too.

Posts: 67
Joined: 01/23/2008

Ryan,
i have started with a module. But i fail to change the textfield into a select box. Is there any sample that can give an idea at least ?

Posts: 23
Joined: 03/13/2008

This is how far I got...Could someone help me to completion.

Here is what I am trying to do.

Trying to change the "textfield" in uc_cart_checkout_form into a "select" field and populate it with a few cities.

For testing I added a check box

I was able to change the title for the "city" now I want it to be of type select and be populated with City1,City2, etc... but was unable to make it happen.

Below is the code.

<?php
function test_form_alter($form_id, &$form) {

  if(
$form_id == "uc_cart_checkout_form")  {

 
$form['test_checkbox'] = array(
   
'#type' => 'checkbox',
   
'#title' => t('Newly Added Test CheckBox'),
    );

 
$form['panes']['delivery']['delivery_city']['#title'] = "TESTING 123";
 
  }
}
?>

Posts: 67
Joined: 01/23/2008

Thanks uberuser, you give me good start point. Here is next step. This is just for one country approach. That will replace the city textfield with select. Just fill your city list to _uc_city_list() method. Also the select can be populated from database.

<?php
function uc_city_form_alter($form_id, &$form) {
  if(
$form_id == "uc_cart_checkout_form")  {
    if (
uc_address_field_enabled('city'))
    {
     
$form['panes']['delivery']['delivery_city'] = array(
     
'#type' => 'select',
     
'#title' => t('City'),
     
'#options' => _uc_city_list() ,
      );

     
$form['panes']['billing']['billing_city'] = array(
     
'#type' => 'select',
     
'#title' => t('City'),
     
'#options' => _uc_city_list() ,
      );
    }
  }
}
function
_uc_city_list()
{
 
$options = array();
 
/* sample for populating form database
   $result = db_query("SELECT city_id,city_name FROM {uc_cities}");
   while ($city = db_fetch_array($result)) {
   $options[$city['city_name']] = $city['city_name'];
   }
   */
 
$options = array(
    
"Test1City" => "Test1City",
    
"Test2City" => "Test2City",
  );
  return
$options;
}
?>

Posts: 23
Joined: 03/13/2008

bakyildiz, thank you for completing it. Could you tell me how to use the db option. I mean how do I create a table and insert the cities (really handicapped here). I am assuming that we would be able to pull up the cities based on the country and zone even if it leads to choosing the city after the country and zone.

Posts: 67
Joined: 01/23/2008

Hi,
Okey. This needs a little bit tehnical background.
You should have a database management tool like myphpadmin which can connect to your database and execute
queries. Here is the create statement. After that you have to edit the table and insert your value.

CREATE TABLE  {uc_cities} (
        `city_country_id` mediumint(11) NOT NULL DEFAULT '0',
        `city_id` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
        `city_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
        PRIMARY KEY (`city_id`),
        KEY `city_country_id` (`city_country_id`)
      )/*!40100 DEFAULT CHARACTER SET UTF8 */;

While the cities are not changing often, there is no need to have management interface. May be we can find more simple way to solve this issue.

Posts: 23
Joined: 03/13/2008

Thanks bakyildiz!!