Fixing Magento error "[unknown object].fireEvent()"

1 1 1 1 1 Fixing Magento error "[unknown object].fireEvent()"5.00Rating 3.53 (19 Votes)

Recently I've encountered the following Javascript error in my Magento store:

error: error in [unknown object].fireEvent():
event name: address_country_changed
error message: zipElement.up(...).down(...) is undefined

This error pops out when creating the order from admin panel and entering customer shipping address. It pops out when editing every filed in the address, which is quite annoying.

Regarding to this forum post, this has something to do with defining the zip code as not required filed in the database. Specialists recommend to set zip code as required filed in the database and then setting it as not required on the country basis. But people report that setting so will still not make zip code as optional field.

So I decided to do my own fix. Here it is:

1. Open the file app\design\adminhtml\default\default\template\directory\js\optional_zip_countries.phtml

2. Navigate approximately to line 57.

3. Find the function setPostcodeOptional(zipElement, country)

4. Find the following line: zipElement.up(1).down('label > span.required').hide();

5. Change it to the following code:

var zipElementLabel = zipElement.up(1).down('label > span.required');
if (zipElementLabel)
    zipElementLabel.hide();

6. Find the following line: zipElement.up(1).down('label > span.required').show();

5. Change it to the following code:

var zipElementLabel = zipElement.up(1).down('label > span.required');
if (zipElementLabel)
    zipElementLabel.show();

Notice that this code repeats two times inside the function, but differs a little bit in "hide()" and "show()" calls at the end.

6. Save the file and upload to the server. Page reload might be required.

This helped me fighting the mentioned error in Magento version 1.5.0.1. I know that this is against Magento policy to modify core files directly, but this seems the only way to fix this annoying error right now. I also appreciate you write any of your considerations in the comments.

If you have some time, I would like to ask you to review my Free Magento Simple Shipping Extension that allows allows to add up to 10 fixed price shipping methods to your Magento shopping cart.

You have no rights to post comments

Thursday the 23rd.