Forum

Thread tagged as: Question, Problem, Shop

Country select not populating in checkout

Hi,

I cant seem to get the country select to populate in the checkout templates for the shop app.

See: https://i.imgur.com/i4tONnM.png

This is the input that's not populating:

<perch:input type="select" options="<perch:shop id="country_list" />" value="236" id="shipping_country" label="Country" />

In the Perch admin, I have created a shipping zone and have selected some countries.

How can I get the select to populate? And what is value="236"?

Thanks.

Jon Young

Jon Young 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Can you post your Diagnostics Report please, you'll find this under Settings in the Perch Control Panel and we need this with each post to the forum - thanks!

Sorry Rachel, please find below.

PERCH INFORMATION

Perch: 2.8.31 Production mode: Production (100) Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), perch_blog (5.0), perch_forms (1.8.3), perch_shop_orders (1.0.8), perch_shop_products (1.0.8), perch_shop (1.0.8), perch_members (1.5) DB driver: PDO DB tables: perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (65), perch2_blog_posts (3), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (7), perch2_category_counts (0), perch2_category_sets (2), perch2_content_index (150), perch2_content_items (39), perch2_content_regions (27), perch2_forms (1), perch2_forms_responses (1), perch2_members (2), perch2_members_forms (2), perch2_members_member_tags (1), perch2_members_sessions (3), perch2_members_tags (1), perch2_navigation (2), perch2_navigation_pages (6), perch2_page_templates (1), perch2_pages (20), perch2_resource_log (46), perch2_resource_tags (0), perch2_resources (45), perch2_resources_to_tags (0), perch2_settings (31), perch2_shop_addresses (44), perch2_shop_admin_index (30), perch2_shop_brands (1), perch2_shop_cart (7), perch2_shop_cart_data (151), perch2_shop_cart_items (7), perch2_shop_countries (250), perch2_shop_currencies (152), perch2_shop_customers (2), perch2_shop_emails (1), perch2_shop_index (143), perch2_shop_option_values (4), perch2_shop_options (1), perch2_shop_order_items (36), perch2_shop_order_promotions (0), perch2_shop_order_statuses (9), perch2_shop_orders (20), perch2_shop_orders_meta (1), perch2_shop_product_files (0), perch2_shop_product_option_values (4), perch2_shop_product_options (1), perch2_shop_product_tags (0), perch2_shop_products (2), perch2_shop_promotions (0), perch2_shop_search (2), perch2_shop_shipping_zone_countries (3), perch2_shop_shipping_zones (1), perch2_shop_shippings (1), perch2_shop_tax_exhibits (29), perch2_shop_tax_group_rates (1), perch2_shop_tax_groups (1), perch2_shop_tax_locations (1), perch2_shop_tax_rates (1), perch2_shop_variants (0), perch2_user_passwords (0), perch2_user_privileges (76), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1) Users: 1 App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_members', 'perch_shop', 'perch_blog', 'perch_forms' ); Scheduled tasks for perch_blog: delete_spam_comments (1440 mins) Editor plug-ins: markitup, tinymce H1: 26cff5ed9a35e3ef442b41eb639945d4 L1: 7a5ae5c1924bd8d3b7d73ac01fe475ac F1: 2edba60ed1f613d6dd804feb202456a2 headerColour: #ffffff content_singlePageEdit: 1 helpURL: siteURL: / hideBranding: 0 content_collapseList: 1 lang: en-gb update_2.8.31: done latest_version: 2.8.15 on_sale_version: 2.8.31 perch_shop_update: 1.0.8 headerScheme: light perch_members_login_page: /login?return={returnURL} perch_shop_price_tax_mode: exc perch_shop_product_url: /the-store/{slug} perch_shop_default_currency: 47 perch_shop_reporting_currency: 47 perch_shop_invoice_number_format: rhapso%d dashboard: 0 hide_pwd_reset: 0 content_hideNonEditableRegions: 0 content_frontend_edit: 0 perch_members_update: 1.4 perch_shop_site_url: https://rhapso.uk perch_blog_update: 5.0.1 perch_blog_post_url: /blog/{postSlug} perch_blog_site_name: perch_blog_slug_format: %Y-%m-%d-{postTitle} perch_blog_akismet_key: perch_blog_max_spam_days: 0 perch_blog_comment_notify: 0 PERCH_DEVELOPMENT: 10 PERCH_STAGING: 50 PERCH_PRODUCTION: 100 PERCH_DB_USERNAME: admin PERCH_DB_SERVER: localhost PERCH_DB_DATABASE: rhapso_perch PERCH_DB_PREFIX: perch2_ PERCH_TZ: Europe/London PERCH_EMAIL_FROM: jon@vitalworks.co.uk PERCH_EMAIL_FROM_NAME: Jon Young PERCH_LOGINPATH: /perch PERCH_PATH: E:\Vital\Local Projects\Rhapso\trunk\Rhapso\perch PERCH_CORE: E:\Vital\Local Projects\Rhapso\trunk\Rhapso\perch\core PERCH_RESFILEPATH: E:\Vital\Local Projects\Rhapso\trunk\Rhapso\perch\resources PERCH_RESPATH: /perch/resources PERCH_HTML5: 1 PERCH_RUNWAY: PERCH_ERROR_MODE: DIE PERCH_DATE_LONG: %d %B %Y PERCH_DATE_SHORT: %d %b %Y PERCH_TIME_SHORT: %H:%M PERCH_TIME_LONG: %H:%M:%S PERCH_RUNWAY_ROUTED: PERCH_STRONG_PASSWORDS: PERCH_DEBUG: PERCH_PREVIEW_ARG: preview PERCH_TEMPLATE_PATH: E:\Vital\Local Projects\Rhapso\trunk\Rhapso\perch\templates PERCH_DEFAULT_DOC: index.php PERCH_DEFAULT_EXT: .php PERCH_PRODUCTION_MODE: 100 PERCH_RWD: PERCH_HTML_ENTITIES: PERCH_SSL: PERCH_STRIPSLASHES: PERCH_PROGRESSIVE_FLUSH: 1 PERCH_PARANOID: PERCH_FORCE_SECURE_COOKIES: PERCH_PASSWORD_MIN_LENGTH: 6 PERCH_MAX_FAILED_LOGINS: 10 PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR PERCH_VERIFY_UPLOADS: PERCH_AUTH_PLUGIN: PERCH_DB_CHARSET: utf8 PERCH_DB_PORT: PERCH_DB_SOCKET: PERCH_SESSION_TIMEOUT_MINS: 20 PERCH_SHOP_VERSION: 1.0.8 PERCH_APPS_EDITOR_PLUGIN: markitup PERCH_APPS_EDITOR_MARKUP_LANGUAGE: textile HOSTING SETTINGS

PHP: 5.6.11 Zend: 2.6.0 OS: WINNT SAPI: apache2handler Safe mode: not detected MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $ MySQL server: 5.6.25 Free disk space: 116.26 GB Extensions: Core, bcmath, calendar, ctype, date, ereg, filter, ftp, hash, iconv, json, mcrypt, SPL, odbc, pcre, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, wddx, xml, xmlreader, xmlwriter, apache2handler, openssl, curl, mbstring, exif, gd, gettext, mysql, mysqli, Phar, pdo_mysql, pdo_sqlite, soap, sockets, sqlite3, xmlrpc, xsl, mhash GD: Yes ImageMagick: No PHP max upload size: 5M PHP max form post size: 8M PHP memory limit: 128M Total max uploadable file size: 5M Resource folder writeable: Yes Session timeout: 24 minutes Native JSON: Yes Filter functions: Yes Transliteration functions: No MIBDIRS: D:/xampp/php/extras/mibs MYSQL_HOME: \xampp\mysql\bin OPENSSL_CONF: D:/xampp/apache/bin/openssl.cnf PHP_PEAR_SYSCONF_DIR: \xampp\php PHPRC: \xampp\php TMP: \xampp\tmp HTTP_HOST: rhapso.dev:81 HTTP_CONNECTION: keep-alive HTTP_CACHE_CONTROL: max-age=0 HTTP_UPGRADE_INSECURE_REQUESTS: 1 HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8 HTTP_ACCEPT_ENCODING: gzip, deflate, sdch HTTP_ACCEPT_LANGUAGE: en-GB,en-US;q=0.8,en;q=0.6 HTTP_COOKIE: p_m=1584903e2e748432e216782a83b2371d1ed63734; cmsa=1; PHPSESSID=56our43jv0eb5ej9rcahfkih70 PATH: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\nodejs\;C:\Program Files\TortoiseSVN\bin;C:\WINDOWS\system32\config\systemprofile.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\The Youngs\AppData\Roaming\npm SystemRoot: C:\WINDOWS COMSPEC: C:\WINDOWS\system32\cmd.exe PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC WINDIR: C:\WINDOWS SERVER_SIGNATURE: <address>Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.11 Server at rhapso.dev Port 81</address> SERVER_SOFTWARE: Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.11 SERVER_NAME: rhapso.dev SERVER_ADDR: 127.0.0.1 SERVER_PORT: 81 REMOTE_ADDR: 127.0.0.1 DOCUMENT_ROOT: E:/Vital/Local Projects/Rhapso/trunk/Rhapso REQUEST_SCHEME: http CONTEXT_DOCUMENT_ROOT: E:/Vital/Local Projects/Rhapso/trunk/Rhapso SERVER_ADMIN: postmaster@localhost SCRIPT_FILENAME: E:/Vital/Local Projects/Rhapso/trunk/Rhapso/perch/core/settings/diagnostics/index.php REMOTE_PORT: 54639 GATEWAY_INTERFACE: CGI/1.1 SERVER_PROTOCOL: HTTP/1.1 REQUEST_METHOD: GET QUERY_STRING: extended REQUEST_URI: /perch/core/settings/diagnostics/?extended SCRIPT_NAME: /perch/core/settings/diagnostics/index.php PHP_SELF: /perch/core/settings/diagnostics/index.php REQUEST_TIME_FLOAT: 1472406417.036 REQUEST_TIME: 1472406417

Drew McLellan

Drew McLellan 2638 points
Perch Support

value="236" is the country ID you wish to default to.

Does <perch:showall /> list your countries?

Ah, ok thanks.

<perch:showall /> just gives me:

ID  Value
perch_page_path /checkout.php
first_name  Jon
last_name   Young
address_1   45 Some Way
address_2   Some place
postcode    MK11 8GD
city    Milton Keynes
county  Buckinghamshire
perch_namespace perch:shop
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which template is this in, and which page function are you using to display it?

It's in a variation of the customer_update.html template and I'm using perch_shop_form() to display it. I've noticed the country dropdown populates if I use perch_shop_edit_address_form(), but the output I want is the below:

https://i.imgur.com/tVoqpfq.png

...and cant get that with perch_shop_edit_address_form().

I have the checkout flow working with perch_shop_form(), but the countries aren't showing.

My template for perch_shop_form() is:

<perch:form id="profile" method="post" app="perch_shop" type="customer" action="/checkout?step=2">
    <h2>Billing address</h2>
    <fieldset>
        <legend hidden>Billing information</legend>     
        <div class="row">
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="first_name" class="sfTxtLbl">First name</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="first_name" required="true" label="First name" class="sfTxt" value='<perch:content id="first_name" />' data-billing="first_name" />
                    </div>
                    <perch:error for="first_name" type="required">
                        <div class="sfError">
                            Please add a first name
                        </div>
                    </perch:error>
                </div>
            </div>
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="last_name" class="sfTxtLbl">Last name</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="last_name" required="true" label="Last name" class="sfTxt" value='<perch:content id="last_name" />' data-billing="last_name" />
                    </div>
                    <perch:error for="last_name" type="required">
                        <div class="sfError">
                            Please add a last name
                        </div>
                    </perch:error>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="address_1" class="sfTxtLbl">Address 1</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="address_1" required="true" label="Address 1" class="sfTxt" value='<perch:content id="address_1" />' data-billing="address_1" />
                    </div>
                    <perch:error for="address_1" type="required">
                        <div class="sfError">
                            Please add an address 1
                        </div>
                    </perch:error>
                </div>
            </div>
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="address_2" class="sfTxtLbl">Address 2</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="address_2" required="true" label="Address 2" class="sfTxt" value='<perch:content id="address_2" />' data-billing="address_2" />
                    </div>
                    <perch:error for="address_2" type="required">
                        <div class="sfError">
                            Please add an address 2
                        </div>
                    </perch:error>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="postcode" class="sfTxtLbl">Post code</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="postcode" required="true" label="Post code" class="sfTxt" value='<perch:content id="postcode" />' data-billing="postcode" />
                    </div>
                    <perch:error for="postcode" type="required">
                        <div class="sfError">
                            Please add a postcode
                        </div>
                    </perch:error>
                </div>
            </div>
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="city" class="sfTxtLbl">Town / City</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="city" required="true" label="Town / City" class="sfTxt" value='<perch:content id="city" />' data-billing="city" />
                    </div>
                    <perch:error for="city" type="required">
                        <div class="sfError">
                            Please add a town or city
                        </div>
                    </perch:error>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="county" class="sfTxtLbl">County or State</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="county"  label="County or State" class="sfTxt" value='<perch:content id="county" />' data-billing="county" />
                    </div>
                    <perch:error for="county" type="required">
                        <div class="sfError">
                            Please add a county
                        </div>
                    </perch:error>
                </div>
            </div>
            <div class="col-xs-12 col-md-6">
                <div class="sfFormDropdown">
                    <perch:label for="country" class="sfTxtLbl">Country</perch:label>
                    <div class="sfDropdownList">
                        <perch:input type="select" id="country" label="Country" class="sfTxt" value='236' options='<perch:shop id="country_list" />' data-billing="country" />
                    </div>
                    <perch:error for="country" type="required">
                        <div class="sfError">
                            Please add a town or country
                        </div>
                    </perch:error>
                </div>
            </div>
        </div>
    </fieldset>
    <h2>Shipping address</h2>
    <div class="sfFormCheckboxlist">
        <div class="sfCheckListBox">
            <input id="sameAsShipping" type="checkbox">
            <label for="sameAsShipping">Shipping address is same as billing or <a href="javascript:;">choose from saved addresses</a></label>
        </div>
    </div>
    <fieldset>
        <legend hidden>Shipping address</legend>    
        <div class="row">
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="shipping_first_name" class="sfTxtLbl">First name</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="shipping_first_name" required="true" label="First name" class="sfTxt" data-shipping="first_name" />
                    </div>
                    <perch:error for="shipping_first_name" type="required">
                        <div class="sfError">
                            Please add a first name
                        </div>
                    </perch:error>
                </div>
            </div>
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="shipping_last_name" class="sfTxtLbl">Last name</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="shipping_last_name" required="true" label="Last name" class="sfTxt" data-shipping="last_name" />
                    </div>
                    <perch:error for="shipping_last_name" type="required">
                        <div class="sfError">
                            Please add a last name
                        </div>
                    </perch:error>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="shipping_address_1" class="sfTxtLbl">Address 1</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="shipping_address_1" required="true" label="Address 1" class="sfTxt" data-shipping="address_1" />
                    </div>
                    <perch:error for="shipping_address_1" type="required">
                        <div class="sfError">
                            Please add an address 1
                        </div>
                    </perch:error>
                </div>
            </div>
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="shipping_address_2" class="sfTxtLbl">Address 2</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="shipping_address_2" required="true" label="Address 2" class="sfTxt" data-shipping="address_2" />
                    </div>
                    <perch:error for="shipping_address_2" type="required">
                        <div class="sfError">
                            Please add an address 2
                        </div>
                    </perch:error>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="shipping_postcode" class="sfTxtLbl">Post code</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="shipping_postcode" required="true" label="Post code" class="sfTxt" data-shipping="postcode" />
                    </div>
                    <perch:error for="shipping_postcode" type="required">
                        <div class="sfError">
                            Please add a postcode
                        </div>
                    </perch:error>
                </div>
            </div>
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="shipping_city" class="sfTxtLbl">Town / City</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="shipping_city" required="true" label="Town / City" class="sfTxt" data-shipping="city" />
                    </div>
                    <perch:error for="shipping_city" type="required">
                        <div class="sfError">
                            Please add a town or city
                        </div>
                    </perch:error>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-md-6">
                <div class="sfFormBox">
                    <perch:label for="shipping_county" class="sfTxtLbl">County or State</perch:label>
                    <div class="sfFieldWrp">
                        <perch:input type="text" id="shipping_county" required="true" label="County or State" class="sfTxt" data-shipping="county" />
                    </div>
                    <perch:error for="shipping_county" type="required">
                        <div class="sfError">
                            Please add a county
                        </div>
                    </perch:error>
                </div>
            </div>
            <div class="col-xs-12 col-md-6">
                <div class="sfFormDropdown">
                    <perch:label for="shipping_country" class="sfTxtLbl">Country</perch:label>
                    <div class="sfDropdownList">
                        <perch:input type="select" id="shipping_country"  label="Country" class="sfTxt" value="236" options='<perch:shop id="country_list" />' data-shipping="country" />
                    </div>
                    <perch:error for="shipping_country" type="required">
                        <div class="sfError">
                            Please add a town or country
                        </div>
                    </perch:error>
                </div>
            </div>
        </div>
    </fieldset>

    <div class="group">
        <perch:input type="submit" value="Next" class="button button-positive right" />
        <perch:input type="hidden" id="token" />
    </div>

</perch:form>

Hey Drew,

Is something wrong with my setup? I'm pretty sure the country list should show in perch_shop_form().

Drew McLellan

Drew McLellan 2638 points
Perch Support

Why are you sure about that?

Try this:

$ShopRuntime = PerchShop_Runtime::fetch();
PerchSystem::set_var('country_list', PerchShop_Countries::get_list_options());

Because why else would you put <perch:input type="select" options="<perch:shop id="country_list" />" value="236" id="country" label="Country" /> in the customer_update.html template?

If perch_shop_form() is the wrong function to use with customer_update.html, then sorry. If not, then the fact it's there leads me to assume the country list should work.

Thanks for your help Drew.

Drew McLellan

Drew McLellan 2638 points
Perch Support

customer_update.html is used by perch_shop_customer_edit_form() not by perch_shop_form().