Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

DHTML State Selection


ecartz

Recommended Posts

Contribution link: DHTML State Selection

 

This add on addresses a missing feature and fixes a bug in address editing. In standard osCommerce, when you add or edit an address, you have to enter the state (or province or county or region or whatever it is called in your country) free hand into a text box. The desired feature being to select from a drop down to avoid typos, etc. Then, if you submit, it replaces your entry with a drop down menu of all the states in that country. However, if you selected the wrong country, you then have to change the country and submit the form to get the correct drop down. That's the bug.

 

This add on dynamically switches between drop down menus for the various countries. For example, with the default osCommerce install, it will allow you to select the United States as the country and then pick Alabama (or any of the other US states) from a drop down menu. Then, if you change your country to Canada, the drop down will show a list of Canadian provinces. If you pick a country that does not have any zones in the database, it will show the standard text input.

 

The add on also defaults the country to the store country setting.

 

There is one feature that is removed. If the user does not have Javascript running in their browser, then this version only ever shows the text input. This fixes the bug of not being able to switch countries but at the price of never offering the convenience of the drop down to a non-javascript user. A possible future enhancement would be to show both the text input and the drop down in this case. However, that was beyond the scope of the current project.

 

Another add on that does something similar via AJAX is Country-State Selector. I haven't used it, so I pass on the question of which is better.

Edited by ecartz

Always back up before making changes.

Link to comment
Share on other sites

  • 1 month later...

Someone would have to modify your store so that STS knew to add the javascript on the appropriate pages. A possible solution might be to change

    </table></form></td>
<!-- body_text_eof //-->

to

    </table></form><?php require('includes/form_check.js.php'); ?></td>
<!-- body_text_eof //-->

and eliminate the other call to form_check. I don't have STS installed, so I can't test it. Or troubleshoot it for that matter.

Always back up before making changes.

Link to comment
Share on other sites

  • 1 month later...

Someone would have to modify your store so that STS knew to add the javascript on the appropriate pages. A possible solution might be to change

    </table></form></td>
<!-- body_text_eof //-->

to

    </table></form><?php require('includes/form_check.js.php'); ?></td>
<!-- body_text_eof //-->

and eliminate the other call to form_check. I don't have STS installed, so I can't test it. Or troubleshoot it for that matter.

 

I've tried manually adding the contents of form_check.js.php and I can't get the js code (what was added) to show. Any ideas?

Link to comment
Share on other sites

  • 3 months later...
It is working only when language is en.
It's not clear to me why the language would make a difference. None of the new SQL queries are language dependent. Also, if I try it on my test site, it works (at least in Spanish and German).

 

Perhaps the problem would be more obvious if you posted a link to the page that is not working?

Always back up before making changes.

Link to comment
Share on other sites

  • 1 year later...

Hi Matt! Tank you so much for a fantastic contribution. I installed it yesterday on my multi language site, and it worked out of the box! :)

 

It does have some glitiches though, which I'd like to fix, example:

 

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 

Date / Time: 24-12-2011 23:02:22

Error Type: [E_NOTICE] Undefined index: US

On line 482

File create_account.php

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 

Date / Time: 24-12-2011 23:05:49

Error Type: [E_NOTICE] Undefined index: telephone

On line 57

File create_account.php

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 

Date / Time: 24-12-2011 23:05:49

Error Type: [E_NOTICE] Undefined index: fax

On line 58

File create_account.php

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

I think these also concerns File includes/modules/address_book_details.php and so on.

 

Also wrt the added file to form check (I might be wrong on this), shouldn't this line

case '<?php echo $country_id_for[$country_with_zones_code]; ?>':

be with double quotes?

 

Also, I am thinking of installing "active countries" to be able to activate/deactivate countries through admin.

Would that possibly be in conflict with yours?

 

I have a list of zones, approx. 4 thousands of them, somewhere. If I find it and it's error free I'll be happy to supply it.

 

 

Anyhow, thanks for a fantastic contribution!

 

Sara

Link to comment
Share on other sites

  • 3 years later...

Hi,

 

I had the same problem, the addon worked when the language was English, but not when the language was Romanian.

After studying the HTML output I found that the form_check.js was not working at all when the language was Romanian. It throws an error because of translation text in the file romana.php.

The line that generated the JS error was like:

 

define('JS_ERROR_SUBMITTED', 'Acest formular a fost deja trimis. Va rugam apasati "Ok" si asteptati ca acest proces sa se incheie.');

 

Just had to remove the " from text.

 

I shared this, just in case someone faces the same problem.

 

Regards

Aurelian

 

P.S.: Thanks Matt for the great Addon  :beers:

Edited by aurelian.zaha
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...