{% extends "commerce/_layouts/cp" %} {% do view.registerAssetBundle('craft\\web\\assets\\admintable\\AdminTableAsset') -%} {% set crumbs = [ { label: "Shipping"|t('commerce'), url: url('commerce/shipping') }, { label: "Shipping Methods"|t('commerce'), url: url('commerce/shipping/shippingmethods') }, ] %} {% set selectedSubnavItem = 'shipping' %} {% set fullPageForm = true %} {% import "_includes/forms" as forms %} {% set tabs = { 0: {'label':'Shipping Method'|t('commerce'),'url':'#shipping-method-tab'} } %} {% if shippingMethod.id %} {% set tabs = tabs|merge({1: {'label':'Rules'|t('commerce'),'url':'#rules'}}) %} {% endif %} {% block saveButton %} {% endblock %} {% block content %}
{{ redirectInput('commerce/shipping/shippingmethods/{id}#rules') }} {% if shippingMethod.id %} {% endif %} {{ forms.textField({ first: true, label: "Name"|t('commerce'), instructions: "The name of shipping method as it will be displayed to the customer and in the control panel."|t('commerce'), id: 'name', name: 'name', value: shippingMethod.getName(), errors: shippingMethod.getErrors('name'), autofocus: true, required: true, }) }} {{ forms.textField({ first: true, label: "Handle"|t('commerce'), instructions: "How this shipping method will be referred to in templates and forms."|t('commerce'), id: 'handle', class: 'code', name: 'handle', value: shippingMethod.handle, errors: shippingMethod.getErrors('handle'), required: true, }) }} {{ forms.lightSwitchField({ label: "Enable this shipping method on the front end"|t('commerce'), id: 'enabled', name: 'enabled', on: shippingMethod.enabled, errors: shippingMethod.getErrors('enabled') }) }}
{% endblock %} {% set tableData = [] %} {% for shippingRule in shippingRules %} {% set details %}

Conditions

{{ "Shipping Zone"|t('commerce') }} {{ shippingRule.shippingZone.name ?? 'Anywhere' }}
{% if shippingRule.minQty > 0 %}{{ "Minimum Order Quantity"|t('commerce') }} {{shippingRule.minQty}}
{% endif %} {% if shippingRule.maxQty > 0 %}{{ "Maximum Order Quantity"|t('commerce') }} {{shippingRule.maxQty}}
{% endif %} {% if shippingRule.minTotal > 0 %}{{ "Minimum Order Total Value"|t('commerce') }} {{shippingRule.minTotal}}
{% endif %} {% if shippingRule.maxTotal > 0 %}{{ "Maximum Order Total Value"|t('commerce') }} {{shippingRule.maxTotal}}
{% endif %} {% if shippingRule.minWeight > 0 %}{{ "Minimum Order Total Weight"|t('commerce') }} {{shippingRule.minWeight}}
{% endif %} {% if shippingRule.maxWeight > 0 %}{{ "Maximum Order Total Weight"|t('commerce') }} {{shippingRule.maxWeight}}
{% endif %}

Costs

{% if shippingRule.baseRate > 0 %}{{ "Base Rate"|t('commerce') }} {{shippingRule.baseRate|commerceCurrency}}
{% endif %} {% if shippingRule.minRate > 0 %}{{ "Minimum Total Shipping Cost"|t('commerce') }} {{shippingRule.minRate|commerceCurrency}}
{% endif %} {% if shippingRule.maxRate > 0 %}{{ "Maximum Total Shipping Cost"|t('commerce') }} {{shippingRule.maxRate|commerceCurrency}}
{% endif %} {% if shippingRule.perItemRate > 0 %}{{ "Default Per Item Rate"|t('commerce') }} {{shippingRule.perItemRate|commerceCurrency}}
{% endif %} {% if shippingRule.weightRate > 0 %}{{ "Default Weight Rate"|t('commerce') }} {{shippingRule.weightRate|commerceCurrency}}
{% endif %} {% if shippingRule.percentageRate > 0 %}{{ "Default Percentage Rate"|t('commerce') }} {{shippingRule.percentageRate|commerceCurrency}}
{% endif %} {% endset %} {% set tableData = tableData|merge([{ id: shippingRule.id, title: shippingRule.name|t('site')|e, url: url('commerce/shipping/shippingmethods/'~shippingRule.methodId~'/shippingrules/'~shippingRule.id), status: shippingRule.enabled ? true : false, description: shippingRule.description|t('site')|e, detail: { handle: tag('span', { 'data-icon': 'info', title: 'Show rule details'|t('commerce')|e }) , content: details } }]) %} {% endfor %} {% js %} {% if not shippingMethod.id %}new Craft.HandleGenerator('#name', '#handle');{% endif %} var columns = [ { name: '__slot:title', title: Craft.t('app', 'Name') }, { name: 'description', title: Craft.t('app', 'Description') }, { name: '__slot:detail', title: '', titleClass: 'thin' }, ]; new Craft.VueAdminTable({ columns: columns, container: '#rules-vue-admin-table', deleteAction: 'commerce/shipping-rules/delete', emptyMessage: Craft.t('commerce', 'No shipping rules exist yet.'), tableData: {{ tableData|json_encode|raw }}, reorderAction: 'commerce/shipping-rules/reorder', reorderFailMessage: Craft.t('commerce', 'Couldn’t reorder rules.'), reorderSuccessMessage: Craft.t('commerce', 'Rules reordered.'), }); {% endjs %}