{% extends "commerce/_layouts/cp" %} {% set crumbs = [ { label: "Store Settings"|t('commerce'), url: url('commerce/store-settings') }, { label: "Currencies"|t('commerce'), url: url('commerce/store-settings/paymentcurrencies') }, ] %} {% set selectedSubnavItem = 'store-settings' %} {% set fullPageForm = true %} {% import "_includes/forms" as forms %} {% block content %} {{ redirectInput('commerce/store-settings/paymentcurrencies') }} {% if currency.id %}{% endif %} {{ forms.selectField({ label: 'Currency Code'|t('commerce'), first: true, instructions: 'Choose the currency’s ISO code.'|t('commerce'), id: 'iso', name: 'iso', value: currency.iso, errors: currency.getErrors('iso'), class: 'selectize fullwidth', }) }} {{ forms.textField({ label: "Conversion Rate"|t('commerce'), instructions: "The conversion rate that will be used when converting an amount to this currency. For example, if an item costs {amount1}, a conversion rate of {rate} would result in {amount2} in the alternate currency."|t('commerce', { amount1: 10|currency(craft.commerce.paymentCurrencies.primaryPaymentCurrency.iso), rate: 1.5, amount2: 15 }), id: 'rate', name: 'rate', disabled: currency.primary, value: currency.rate ? currency.rate + 0 : 1, errors: currency.getErrors('rate') }) }} {% if currency.primary %} {% endif %} {% endblock %} {% js %} window.currencies = {{ craft.commerce.currencies.allcurrencies|values|json_encode|raw }}; window.currency = {{ [currency.iso]|json_encode|raw }}; $(function () { $('#iso').selectize({ options: window.currencies, items : window.currency, render: { item: function(item, escape) { return '
' + (item.currency ? '' + escape(item.currency) + '' : '') + (item.alphabeticCode ? ' (' + escape(item.alphabeticCode) + ')' : '') + '
'; }, option: function(item, escape) { var label = item.currency || item.alphabeticCode; var caption = item.currency ? item.alphabeticCode : null; return '
' + '' + escape(label) + '' + (caption ? ' (' + escape(caption) + ')' : '') + '
'; } }, valueField: 'alphabeticCode', labelField: 'currency', sortField: 'currency', searchField: ['currency', 'iso'], dropdownParent: 'body', maxItems: 1 }); }); {% endjs %}