{% extends 'market/_layouts/cp' %} {% import '_includes/forms' as forms %} {% set fullPageForm = true %} {% set saveShortcutRedirect = continueEditingUrl %} {% set retainScrollOnSaveShortcut = true %} {% set selectedSubnavItem = 'shipping' %} {% set isNewProfile = shippingProfile.id ? false : true %} {% set formActions = [ { label: 'Save and continue editing'|t('app'), redirect: continueEditingUrl|hash, shortcut: true, retainScroll: true, }, not isNewProfile ? { destructive: true, label: 'Delete shipping profile'|t('market'), action: 'market/shipping/delete-shipping-profile', redirect: 'market/shipping#'|hash, confirm: 'Are you sure you want to delete this shipping profile?'|t('market'), } ]|filter %} {% block content %} {{ actionInput('market/shipping/save-shipping-profile') }} {{ redirectInput('market/shipping') }} {% if shippingProfile.id %}{{ hiddenInput('profileId', shippingProfile.id) }}{% endif %} {{ forms.textField({ first: true, label: 'Name'|t('app'), instructions: 'What this shipping profile will be called, this will be seen by customers during checkout.'|t('market'), id: 'name', name: 'name', value: shippingProfile.name, errors: shippingProfile.getErrors('name'), autofocus: true, required: true, }) }} {{ forms.elementSelectField({ label: 'Vendor'|t('market'), instructions: 'The Vendor this profile is for.'|t('market'), id: 'vendorId', name: 'vendorId', elementType: vendorElementType, selectionLabel: 'Choose'|t('app'), limit: 1, elements: (vendor is defined and vendor ? [vendor]), required: true, errors: shippingProfile.getErrors('vendorId'), }) }} {{ forms.selectField({ label: 'Origin Country'|t('market'), instructions: 'Where this profile is shipping from in the world (usually wherever the vendor is).'|t('market'), id: 'originCountryId', name: 'originCountryId', options: originCountryOptions, value: shippingProfile.originCountry ? shippingProfile.originCountry.id : vendorSettings.shippingOriginId, errors: shippingProfile.getErrors('originCountryId'), required: true, }) }} {{ forms.selectField({ label: 'Processing Time'|t('market'), instructions: 'How long it takes you to ship this item.'|t('market'), id: 'processingTime', name: 'processingTime', options: processingTimeOptions, value: shippingProfile.processingTime, errors: shippingProfile.getErrors('processingTime'), required: true, }) }}
{% set cols = { zone: { heading: 'Destination Zone *'|t('market'), type: 'select', class: 'thin', options: zoneOptions, required: true }, primaryRate: { heading: 'Primary Rate *'|t('market'), type: 'number' }, secondaryRate: { heading: 'Secondary Rate'|t('market'), type: 'number' }, deliveryTime: { heading: 'Delivery Time *'|t('market'), type: 'singleline' } } %} {{ forms.editableTableField({ label: 'Shipping Costs'|t('market'), instructions: 'Add a shipping cost for each destination you ship to.'|t('market'), id: 'destinations', name: 'destinations', addRowLabel: 'Add a destination'|t('market'), maxRows: zoneOptions|length, initJs: false, cols: cols, rows: destinationsTableRows, }) }} {# Handle shipping destination errors #} {% set errors = shippingProfile.getErrors('shippingDestinations') %} {% for shippingDestination in shippingProfile.getShippingDestinations() %} {% set rowCount = loop.index %} {% for rowErrors in shippingDestination.getErrors() %} {% for error in rowErrors %} {% set errors = errors|push('Row #'~rowCount~': '~error) %} {% endfor %} {% endfor %} {% endfor %} {% if errors %} {% endif %} {% set jsId = 'destinations'|namespaceInputId|e('js') %} {% set jsName = 'destinations'|namespaceInputName|e('js') %} {% set jsCols = cols|json_encode %} {% js %} new Craft.EditableTable("{{ jsId }}", "{{ jsName }}", {{ jsCols|raw }}, { rowIdPrefix: 'new:', maxRows: {{ zoneOptions|length }} }); {% endjs %} {% endblock %}