{% extends "commerce/_layouts/store-settings" %} {% import "_includes/forms" as forms %} {% block content %}
{{ 'This is the address where your store is located. It may be used by various plugins to determine things like shipping and taxes. It could also be used in PDF receipts.'|t('commerce') }}
{% set statesByCountryId = craft.commerce.states.allStates|group('countryId') %} {% set startingStates = statesByCountryId[storeLocation.countryId] ?? [] %} {% js %} window.statesByCountryId = {{ statesByCountryId|json_encode|raw }}; var stateField = $('#stateValue-field').find('select').selectize({ valueField: 'id', create: true, items: ['{{ storeLocation.stateValue }}'], options: {{ startingStates|json_encode|raw }}, labelField: 'name', searchField: ['name'], dropdownParent: 'body', inputClass: 'selectize-input text', allowEmptyOption: false }); var selectize = stateField[0].selectize; var countryField = $('#countryId'); countryField.on('change', function(ev) { selectize.clearOptions(); if (window.statesByCountryId[countryField.val()] !== undefined) { selectize.addOption(window.statesByCountryId[countryField.val()]); } selectize.refreshOptions(); }); {% endjs %} {% css %} .selectize-dropdown.single { margin-bottom: 1rem; } {% endcss %} {% endblock %}