We’ve migrated our documentation to a new site, which means some URLs have changed.
Subscriptions

How to set a default country value into the print address collection screen

In order to prefill a default country value into the print address collection screen during checkout, you would need to add the below code to the Print address collect screen template:

HTML
 <input type="radio" ng-model="model.activeItem" ng-value="'add_new'" id="add_new" class="selectable-list-radiobutton" onclick="var inter = setInterval(function(){var country_select =  document.getElementById('country'); if (typeof(country_select) != 'undefined' &amp;&amp; country_select != null) { document.getElementsByClassName('field-region')[0].style.visibility = 'hidden';  country_select.value='<country_name>'; var event = new Event('change'); country_select.dispatchEvent(event); clearInterval(inter)}}, 200);">
image

You would just replace the value <country_name> for the country_select.value parameter with the name of the country, which should be prefilled.

In addition, if your country does not have any regions, you can also hide the field Region input field from the print address collection screen by adjusting the country selector code of the Print address collect screen template.

From:

HTML
<div class="floating-table-cell field-country">
                    <div class="shake-element">
                        <label for="country">
                            <t>Country</t>
                        </label>
                        <div>
                            <select id="country"
                                    required
                                    ng-model="model.country"
                                    ng-options="country.countryName for country in countryList() track by country.countryName">
                            </select>
                        </div>
                    </div>
                </div>

To:

HTML
<div class="floating-table-cell field-country">
                    <div class="shake-element">
                        <label for="country">
                            <t>Country</t>
                        </label>
                        <div>
                            <select id="country"
                                    required
                                    ng-model="model.country"
                                    ng-options="country.countryName for country in countryList() track by country.countryName"
                                    onchange="if(document.getElementById('country').value == '<country_name>') {document.getElementsByClassName('field-region')[0].style.visibility = 'hidden';} else{document.getElementsByClassName('field-region')[0].style.visibility = 'visible';}" >
                            </select>
                        </div>
                    </div>
                </div>

Again, replacing the value <country_name> with the actual name of your country.

Last updated: