{% import "_includes/forms" as forms %}
{% do view.registerTranslations('commerce', [
"Example"
]) %}
{{ forms.textField({
first: true,
label: "Name"|t('commerce'),
instructions: "What this tax zone will be called in the CP."|t('commerce'),
id: 'name',
name: 'name',
value: taxZone is defined ? taxZone.name,
errors: taxZone is defined ? taxZone.getErrors('name'),
autofocus: true,
required: true
}) }}
{{ forms.textField({
label: "Description"|t('commerce'),
instructions: "Describe this tax zone."|t('commerce'),
id: 'description',
name: 'description',
value: taxZone is defined ? taxZone.description,
errors: taxZone is defined ? taxZone.getErrors('description'),
}) }}
{% if craft.commerce.settings.useBillingAddressForTax %}
{% set labelDefault = "Default to this tax zone when no billing address is set"|t('commerce') %}
{% else %}
{% set labelDefault = "Default to this tax zone when no shipping address is set"|t('commerce') %}
{% endif %}
{{ forms.checkboxField({
label: labelDefault,
id: 'default',
name: 'default',
value: 1,
checked: taxZone is defined ? taxZone.default,
errors: taxZone is defined ? taxZone.getErrors('default')
}) }}
{{ forms.radioGroupField({
label: 'Type'|t('commerce'),
id: 'isCountryBased',
name: 'isCountryBased',
options: {1 : 'Country-based'|t('commerce'), 0 : 'State-based'|t('commerce')},
value: taxZone is defined ? taxZone.isCountryBased,
errors: taxZone is defined ? taxZone.getErrors('isCountryBased'),
required: true,
}) }}
{{ forms.multiselectField({
label: 'Countries'|t('commerce'),
instructions: 'Choose the countries that this zone applies to.'|t('commerce'),
id: 'countries',
name: 'countries',
options: countries,
values: taxZone is defined ? taxZone.getCountryIds(),
errors: taxZone is defined ? taxZone.getErrors('countries'),
required: true,
class: 'selectize fullwidth',
}) }}
{{ forms.multiselectField({
label: 'States'|t('commerce'),
id: 'states',
instructions: 'Choose the states that this zone applies to.'|t('commerce'),
name: 'states',
options: states,
values: taxZone is defined ? taxZone.getStateIds(),
errors: taxZone is defined ? taxZone.getErrors('states'),
required: true,
class: 'selectize fullwidth',
}) }}
{% embed '_includes/forms/field' with {
label: 'Zip Code Condition Formula'|t('commerce'),
id: 'zipCodeConditionFormula',
rows: 5,
instructions: 'Use a formula to match the zip code. Leave this blank to match all zip codes. Use the `zipCode` variable.',
tip: 'This field uses the Twig expression syntax. Learn More',
errors: taxZone is defined ? taxZone.getErrors('zipCodeConditionFormula'),
} %}
{% block input %}
{% import "_includes/forms" as forms %}
{% embed '_includes/forms/field' with {
label: 'Test Zip Code'|t('commerce'),
class: 'zip-test-input',
instructions: 'Type a test zip to see if your match works.'|t('commerce'),
fieldClass: 'last'
} only %}
{% block input %}
{% import "_includes/forms" as forms %}