diondp Posted July 29, 2011 Share Posted July 29, 2011 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 More sharing options...
rocky Posted July 29, 2011 Share Posted July 29, 2011 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 More sharing options...
diondp Posted August 1, 2011 Author Share Posted August 1, 2011 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 More sharing options...
jhnstcks Posted August 1, 2011 Share Posted August 1, 2011 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 More sharing options...
diondp Posted August 1, 2011 Author Share Posted August 1, 2011 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 More sharing options...
andusbeckus Posted October 4, 2011 Share Posted October 4, 2011 Did you manage to find a solution as I am having the same problem! Thanks Link to comment Share on other sites More sharing options...
diondp Posted November 24, 2011 Author Share Posted November 24, 2011 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 :-) 1 Link to comment Share on other sites More sharing options...
Dave L Posted November 24, 2011 Share Posted November 24, 2011 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 More sharing options...
zpages Posted August 10, 2012 Share Posted August 10, 2012 Do you know any other better solution instead of transparent picture like diondp posted in this thread? There must be more "clear" solution how to solve the problem. Link to comment Share on other sites More sharing options...
jincmd Posted January 9, 2013 Share Posted January 9, 2013 Dion could you tell us more Link to comment Share on other sites More sharing options...
carpzerkalniy Posted May 20, 2014 Share Posted May 20, 2014 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" /> Link to comment Share on other sites More sharing options...
spott Posted July 3, 2014 Share Posted July 3, 2014 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) 1 Link to comment Share on other sites More sharing options...
rdaraujo Posted May 22, 2015 Share Posted May 22, 2015 (edited) 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 May 31, 2015 by rdaraujo (see edit history) Link to comment Share on other sites More sharing options...
mike_101 Posted September 10, 2015 Share Posted September 10, 2015 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" /> Thank you good sir! Link to comment Share on other sites More sharing options...
chahidkhan Posted February 11, 2016 Share Posted February 11, 2016 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): Le pays ne peut pas être chargé avec address->id_country Pays invalide country ID requis nom requis prénom requis any help please ? thnx in advance Link to comment Share on other sites More sharing options...
Recommended Posts