Country formats

Posts: 71
Joined: 04/05/2008
Bug Finder

Each CIF file has a country format in it, right?

Is this supposed to be loaded automatically on

Administer › Store administration › Configuration > Country Settings > Edit > Country formats ????

Because United States has the text field with stuff in it. But other countries i import, their text fields are empty.

I know i can type stuff there, thats not my issue.
All i need to know is if its supposed to load that stuff automatically from the CIF file or not.

Posts: 71
Joined: 04/05/2008
Bug Finder

This is what i mean, check attachment.

As you see there, the US format (default) has something there while the Mozambique format (a new one i imported) has nothing.

AttachmentSize
ubercart country formats.png25.96 KB
Posts: 3959
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Interesting... it should certainly have something in there. I'll review it on Monday and get back to ya! Thanks for posting it up. Smiling

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

This issue isn't occurring on the Livetest. Are address formats showing up for any other countries besides Mozambique/U.S.? It may have just been a problem w/ the Mozambique .cif when you first installed it. You can also try removing and reinstalling that country to see if that fixes it.

EDIT: Upon closer inspection, it seems that some arbitrarily are missing address formats. I don't know why. Smiling I'll have to investigate further... and also investigate my idea of storing the formats in the variables table. Bwuh? Sticking out tongue

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

Ok... I'm not sure what here applies to Mozambique, but I discovered three related issues. Shocked They were:

  1. Some countries were using the wrong country ID for the address format, most likely just a copy mistake and usually from Austria. Sticking out tongue I fixed these.
  2. Some countries were using a leading 0 that was screwing up PHP's intval() or something so that it evaluated to 32 instead of the real ID. Puzzled In any event, I took out the leading 0's.
  3. The uc_set_address_format() function was getting a validated country ID and then not using it. Fixed that.

These changes will be committed shortly.

(Oh, I also got tired of scrolling down when importing new countries, so I moved the import form above the table and updated the help text. Smiling)

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

As far as the intval() thing goes, PHP interprets leading 0's on numbers as octal (base Cool numbers. If it finds an 8 or 9 in the number, it just stops and uses what it has so far. "048" and "049" are therefore 32 in octal (4 * Cool.

Posts: 71
Joined: 04/05/2008
Bug Finder

Hi Ryan,

Im using Drupal 5.7 and Uber RC4 and I was having trouble trying to update one of my countries (Mozambique).

I tried new versions, etc, the change (a small province name change) i did on the file wouldnt show up.

Ended up deleting all orders, removing the country and enabling again. Only then it showed.

I think you should look into this.

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

Hmm... to make an update you should have to add an update function and rename the file to reflect the current version. You also have to make the change in the install function. Alternately, you could just tweak it in your database directly...

The existing country system is technical and should be made easier... that's a broader goal for 2.0.

Posts: 71
Joined: 04/05/2008
Bug Finder

Hi,

All i did to "update" was change file names (from mozambique_508_1.cif to mozambique_508_2.cif) and also one line inside the file:

db_query("INSERT INTO {uc_countries} VALUES (508, 'Mozambique', 'MZ', 'MOZ', 1)");
to
db_query("INSERT INTO {uc_countries} VALUES (508, 'Mozambique', 'MZ', 'MOZ', 2)");

So, you're saying this isnt enough ?

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

Yeah, you'd also have to add something like this to your mozambique_update() function:

<?php
switch ($version) {
  case
2:
   
// do your update query...
   
break;
}
?>

Although since Mozambique isn't in core yet, I'd just change it and leave it as version 1. We don't really need updates until something been committed and is in public use.

Posts: 71
Joined: 04/05/2008
Bug Finder

I'm leaving the file on this website as version 1.

But the update thing was actually on my test server.

I'm not sure about the "update query" .
Could you post full code (an example) ?

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

Not sure... whatever it takes, like:

<?php
db_query
("UPDATE {uc_zones} SET zone_name = 'New name' WHERE zone_country_id = 508 AND zone_name = 'Old name'");
?>