Wednesday, June 2, 2010

Default Country - Bug in IE 6-8

It seems I never wrote about this strange bug before, so here goes...

Problem description
If a customer use the Swedish Internet Explorer 6, 7, or 8 PrestaShop thinks they are located in El Salvador.

This is because of a bug in IE. IE sends the Language Code (SV for Sweden) intead of the Country Code (SE for Sweden, SV for El Salvador) to the server.
Since the bug appeared as early as in ver 6 of IE, one would think that the bug would be solved by now, but I guess it's not regarded severe enough.

Client side workaround
One workaround would be to add .se as suffix in IE (Verktyg, Internetalternativ, Språk), but since that only fix the problem for that single client it's not really a solution.

Solution
The way I solved it was to hardcode it in the PrestaShop code, like this:
In themes/prestashop (or whatever your themes folder is called)/authentication.tpl change $sl_country to the number that represents Sweden in your installation of PrestaShop (in mine it's 18 but could be something else for you)

I.e. change

{foreach from=$countries item=v}
<option value="{$v.id_country}" {if ($sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
{/foreach}

to

{foreach from=$countries item=v}
<option value="{$v.id_country}" {if (18 == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
{/foreach}


PS Note to self: use this to include code in blog posts

No comments:

Post a Comment