drmtr Posted February 28, 2018 Share Posted February 28, 2018 i work on WHMCS customizations, and want to hide Contry selector field. I tryed to comment county from template, and field are not shown, but when try to checkout, i got this error: Please correct the following errors before continuing: Please choose your country from the drop down box I commented the code into checkout.tpl <div class="col-sm-12"> <div class="form-group prepend-icon"> <label for="inputCountry" class="field-icon" id="inputCountryIcon"> <i class="fa fa-globe"></i> </label> <select name="country" id="inputCountry" class="field"{if $loggedin} disabled="disabled"{/if}> {foreach $countries as $countrycode => $countrylabel} <option value="{$countrycode}"{if (!$country && $countrycode == $defaultcountry) || $countrycode eq $country} selected{/if}> {$countrylabel} </option> {/foreach} </select> </div> </div> and this: i work on WHMCS customizations, and want to hide Contry selector field. I tryed to comment county from template, and field are not shown, but when try to checkout, i got this error: Please correct the following errors before continuing: Please choose your country from the drop down box enter image description here This is Code from template that handle that part: <div class="col-sm-12"> <div class="form-group prepend-icon"> <label for="inputCountry" class="field-icon" id="inputCountryIcon"> <i class="fa fa-globe"></i> </label> <select name="country" id="inputCountry" class="field"{if $loggedin} disabled="disabled"{/if}> {foreach $countries as $countrycode => $countrylabel} <option value="{$countrycode}"{if (!$country && $countrycode == $defaultcountry) || $countrycode eq $country} selected{/if}> {$countrylabel} </option> {/foreach} </select> </div> </div> and also this one: <div class="col-sm-12"> <div class="form-group prepend-icon"> <select name="domaincontactcountry" id="inputDCCountry" class="field"> {foreach $countries as $countrycode => $countrylabel} <option value="{$countrycode}"{if (!$domaincontact.country && $countrycode == $defaultcountry) || $countrycode eq $domaincontact.country} selected{/if}> {$countrylabel} </option> {/foreach} </select> </div> </div> </div> So how to disable that error? Link to comment Share on other sites More sharing options...
brian! Posted March 1, 2018 Share Posted March 1, 2018 20 hours ago, drmtr said: i work on WHMCS customizations, and want to hide Contry selector field. I tryed to comment county from template, and field are not shown, but when try to checkout, i got this error: because you can't make the country field optional from the settings, you will have to pass it as a hidden field in the template - that will remove the error message. Link to comment Share on other sites More sharing options...
drmtr Posted March 1, 2018 Author Share Posted March 1, 2018 Hi thanks for answer.. I edit template checkout.tpl and have commented that lines for country so selector is not shown in checkout. But when try to place order is showing that error. So looks like i dont edit right template for that.. Link to comment Share on other sites More sharing options...
WHMCS ChrisD Posted March 1, 2018 Share Posted March 1, 2018 Hi @drmtr as indicated by @brian! the country field cannot be optional it must contain a country. You would need to still pass the country into the hidden feild as outlined in the thread he provided https://whmcs.community/topic/256805-problems-with-how-to-make-quotcountryquot-optional-on-checkout/?do=findComment&comment=1185157 Link to comment Share on other sites More sharing options...
brian! Posted March 2, 2018 Share Posted March 2, 2018 22 hours ago, drmtr said: Hi thanks for answer.. I edit template checkout.tpl and have commented that lines for country so selector is not shown in checkout. But when try to place order is showing that error. So looks like i don't edit right template for that.. @WHMCS ChrisD is correct and you need to do this in two steps... remove the 'country' dropdown from checkout.tpl add the field back as a hidden field. so if you take v7.4.2 standard_cart/checkout as an example... first remove (or remark out) the country field part of the form... <!-- <div class="col-sm-12"> <div class="form-group prepend-icon"> <label for="inputCountry" class="field-icon" id="inputCountryIcon"> <i class="fa fa-globe"></i> </label> <select name="country" id="inputCountry" class="field"{if $loggedin} disabled="disabled"{/if}> {foreach $countries as $countrycode => $countrylabel} <option value="{$countrycode}"{if (!$country && $countrycode == $defaultcountry) || $countrycode eq $country} selected{/if}> {$countrylabel} </option> {/foreach} </select> </div> </div> --> then add it as a hidden field... <input type="hidden" name="country" value="US"> 1 Link to comment Share on other sites More sharing options...
drmtr Posted March 7, 2018 Author Share Posted March 7, 2018 Thanks. That was very helpfull. Link to comment Share on other sites More sharing options...
Recommended Posts