Jump to content

remove country dropdown completely


Recommended Posts

Hi There, i am using PS 1.4.3 and OPC

 

i have commented out a lot of unwanted fields in the checkout form...

 

but i am having trouble with removing countries dropdown without it giving error on save "id_country" needed

 

it is this piece of code in order-opc-new-account.tpl

 

i have tried making an hidden inputfield, since i only want one country.DK (id: 20)

 

<input type="hidden" id="id_country" name="id_country" value="20">

 

but this does not work :(

 

{elseif $field_name eq "country" || $field_name eq "Country:name"}

 

<p class="required select">

<label for="id_country">{l s='Country'}</label>

<select name="id_country" id="id_country">

<option value="">-</option>

{foreach from=$countries item=v}

<option value="{$v.id_country}" {if (isset($guestInformations) AND $guestInformations.id_country == $v.id_country) OR (!isset($guestInformations) && $sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>

{/foreach}

</select>

<sup>*</sup>

</p>

Link to comment
Share on other sites

You can't remove the country field, since it's required. I suggest hiding it with CSS instead of deleting it. Try changing <p class="required select"> to <p class="required select hidden"> or if that doesn't work try <p class="required select" style="display:none">

Link to comment
Share on other sites

You can't remove the country field, since it's required. I suggest hiding it with CSS instead of deleting it. Try changing <p class="required select"> to <p class="required select hidden"> or if that doesn't work try <p class="required select" style="display:none">

 

Hi, i tried both of your suggestions but it still errors in:

 

01.id_country required

 

i think it is wierd that it gives an error, even if i hardcode an <input select="hidden"> it seems like if it is hidden then it is no go... but i dont want to show this dropdown since it is stupid when only delivering to one country...

 

checkout should be as simple and easy as possible, therefore i want this changed..

Link to comment
Share on other sites

Its failing because the country is required, but if you hide the dropdown then it will try to use - which is what is selected.

You can't remove the country field, since it's required. I suggest hiding it with CSS instead of deleting it. Try changing <p class="required select"> to <p class="required select hidden"> or if that doesn't work try <p class="required select" style="display:none">

 

Hi, i tried both of your suggestions but it still errors in:

 

01.id_country required

 

i think it is wierd that it gives an error, even if i hardcode an <input select="hidden"> it seems like if it is hidden then it is no go... but i dont want to show this dropdown since it is stupid when only delivering to one country...

 

checkout should be as simple and easy as possible, therefore i want this changed..

Link to comment
Share on other sites

well i have tried it, at it still gives the error reported earlier...

 

this can't be right, there must be a way to omit this, hardcode it, or hide it without getting and error...

 

i have tried the "required select hidden" which hides the dropdown, but it gives the error on saving the form... country must be filled, i have even tried to make the first "-" option to "20" which should be id for Denmark

 

Its failing because the country is required, but if you hide the dropdown then it will try to use - which is what is selected.

You can't remove the country field, since it's required. I suggest hiding it with CSS instead of deleting it. Try changing <p class="required select"> to <p class="required select hidden"> or if that doesn't work try <p class="required select" style="display:none">

 

Hi, i tried both of your suggestions but it still errors in:

 

01.id_country required

 

i think it is wierd that it gives an error, even if i hardcode an <input select="hidden"> it seems like if it is hidden then it is no go... but i dont want to show this dropdown since it is stupid when only delivering to one country...

 

checkout should be as simple and easy as possible, therefore i want this changed..

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

I Have solved it. simply by adding a picture which is transparent 1x1 px.

 

like this:

 

comment out the "country" option in the TPL.

 

insert this: (find the id for the country you need, my case is DK which is id "20"

 

<input type="image" name="id_country" id="id_country" value="20" checked="checked" src="/themes/prestashop/dot.gif" style="border:0px">

 

make a picture call dot.gif (or else it will result in an error)

 

This method is not the 100% proper way of solving this (that would be to remove the check on the form field etc. lot more work), however this solution works 100% without any problems because the field is there and validates, still invisible to the frontend..

 

remember to backup always, no guarantee.

 

you can use above method for any of the fields for which you prefer a static value etc.

ps.

if you can't do this yourself i can do it for a small fee :-)

  • Like 1
Link to comment
Share on other sites

Could you not just disable the countries you don't use so they don't appear in the drop down and adjust the code so the default country is selected ?

 

There's another module (not a checkout module) that requires a country to be selected but has the default country pre-selected instead of the dash.

Now, I'm not a programmer and know little about coding but this is from the modules .php file:

 

$countries = Country::getCountries(intval($cookie->id_lang), true);
   $defaultCountry = Configuration::get('PS_COUNTRY_DEFAULT');

 

Couldn't something like this be used in this case?

 

 

 

ps.

if you can't do this yourself i can do it for a small fee :-)

 

Not impressed!!!

Link to comment
Share on other sites

  • 8 months later...
  • 4 months later...
  • 1 year later...
  • 1 month later...

 

a little more accurate way - is to use <input type="hidden"> instead of hidden <img>

<input type="hidden" name="id_country" id="id_country" value="177" checked="checked" />

Thanks - it works fine (Presta 1.6)

  • Like 1
Link to comment
Share on other sites

  • 10 months later...

Sorry for replying an old post, I believe it can help others.

 

I'm using version 1.5.4.1 and guest chekout disabled.

 

To remove Country field from Account Creation form I did like that:

 

- Backup all files involved.

 

- authentication.tpl

Remove or comment "Country" combobox around line 517 where it has {elseif $field_name eq "Country:name" || $field_name eq "country"}.

Example:

                <!--
            {elseif $field_name eq "Country:name" || $field_name eq "country"}
                <p class="required select">
                    <label for="id_country">{l s='Country'} <sup>*</sup></label>
                    <select name="id_country" id="id_country">
                        <option value="">-</option>
                        {foreach from=$countries item=v}
                        <option value="{$v.id_country}" {if ($sl_country == $v.id_country)} selected="selected"{/if}>{$v.name}</option>
                        {/foreach}
                    </select>
                </p>
                -->

- authentication.css

Remove "State" combobox from being hidden by CSS. Edit around line 77 like that:

#account-creation_form .dni, #account-creation_form .postcode {

- statesManagement.js

Remove "State" combobox from being hidden by inline HTML code. Edit around line 8 like that:

$('.dni, .postcode').css({'display':'none'});

In line 36 change from this:

var states = countries[$('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val()];

to this:

var states = countries[XX]; // XX is your Country id. Look at Back Office, option Localization > Countries, id column

I have tested creating an account and all seems fine. The new register got saved on "customer" table. More tests are needed though.

Edited by rdaraujo (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 5 months later...

Hello ,

 

I tried everything in this post to remove country field from guest checkout in prestashop 1.5.6.2 but i get this error :

 

Il y a 5 erreur(s):

  1. Le pays ne peut pas être chargé avec address->id_country
  2. Pays invalide
  3. country ID requis
  4. nom requis
  5. prénom requis

any help please ?

 

thnx in advance

Link to comment
Share on other sites

×
×
  • Create New...