Jump to content

WHMCS Remove “Country” selector from checkout page


drmtr

Recommended Posts

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

auaeS.png

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

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

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

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

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...

  1. remove the 'country' dropdown from checkout.tpl
  2. 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">

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated