{{ forms.textField({
first: true,
label: "Name"|t('commerce'),
instructions: "What this shipping rule will be called in the control panel."|t('commerce'),
id: 'name',
name: 'name',
value: shippingRule.name,
errors: shippingRule.getErrors('name'),
autofocus: true,
required: true,
}) }}
{{ forms.textField({
first: true,
label: "Description"|t('commerce'),
instructions: "Describe this rule."|t('commerce'),
name: 'description',
value: shippingRule.description,
errors: shippingRule.getErrors('description'),
}) }}
{{ forms.lightSwitchField({
label: "Enable this shipping rule"|t('commerce'),
id: 'enabled',
name: 'enabled',
value: 1,
on: shippingRule.enabled,
checked: shippingRule.enabled,
errors: shippingRule.getErrors('enabled')
}) }}
{{ "Filtering conditions which describe to which orders this rule is applicable to. Write 0 to skip a condition."|t('commerce') }}
{% set shippingZoneSelectParams = {
label: "Shipping Zone"|t('commerce'),
instructions: "Select a shipping zone."|t('commerce'),
id: 'shippingZoneId',
name: 'shippingZoneId',
value: shippingRule.shippingZoneId,
errors: shippingRule.getErrors('shippingZoneId'),
required: false,
options: shippingZones,
class: 'selectize fullwidth',
} %}
{{ lazyCreateSelect(
shippingZoneSelectParams,
'New shipping zone'|t('commerce'),
'Create a new shipping zone'|t('commerce'),
newShippingZoneFields,
newShippingZoneJs,
'commerce/shipping-zones/save',
'Shipping zone saved.'|t
) }}
{% embed '_includes/forms/field' with {
label: 'Order Condition Formula'|t('commerce'),
id: 'orderConditionFormula',
rows: 5,
instructions: 'Specify a Twig condition that determines whether the shipping rule should apply to a given order. (The order can be referenced via an `order` variable.)'|t('commerce', {
url: 'https://twig.symfony.com/doc/2.x/templates.html#expressions',
}),
errors: shippingRule is defined ? shippingRule.getErrors('orderConditionFormula'),
} %}
{% block input %}
{% import "_includes/forms" as forms %}
{{ forms.textarea({
value: shippingRule is defined ? shippingRule.orderConditionFormula,
name: 'orderConditionFormula',
class: 'code',
rows: 5,
placeholder: 'Example'|t('commerce') ~ ': \'@apple.com\' in order.email'
}) }}
{% endblock %}
{% endembed %}
{% set minMaxTotalQtyInput %}
{% endset %}
{{ forms.field({
label: "Order Total Quantity"|t('commerce'),
instructions: "The total number of items in the cart to match this rule. A zero value disables the limit for each condition."|t('commerce'),
id: 'minMaxTotalQty',
required: true
}, minMaxTotalQtyInput) }}
{% set minMaxTotalInput %}
{{ forms.selectField({
id: 'minMaxTotalType',
label: ' ',
name: 'minMaxTotalType',
options: [
{label: "Value of products before any discounts are applied."|t('commerce'), value: 'salePrice'},
{label: "Value of products with applied discounts."|t('commerce'), value: 'salePriceWithDiscounts'}
],
value: shippingRule.minMaxTotalType
}) }}
{% endset %}
{{ forms.field({
label: "Order Total Value"|t('commerce'),
instructions: "The total value of items (excluding shipping and taxes) in the cart to match this rule. A zero value disables the limit for each condition."|t('commerce'),
id: 'minMaxTotal',
required: true,
}, minMaxTotalInput) }}
{% set minMaxTotalWeightInput %}
{% endset %}
{{ forms.field({
label: "Order Total Weight"|t('commerce'),
instructions: "The weight of the cart to match this rule. A zero value disables the limit for each condition."|t('commerce'),
id: 'minMaxTotalWeight',
required: true,
}, minMaxTotalWeightInput) }}
{{ commerceForms.numberField({
label: "Base Rate"|t('commerce'),
name: 'baseRate',
instructions: "Shipping costs added to the order as a whole before percentage, item, and weight rates are applied. Set to zero to disable this rate. The whole rule, including this base rate, will not match and apply if the cart only contains non-shippable items like digital products."|t('commerce'),
value: shippingRule.baseRate,
type: 'number',
min: 0,
step: 'any',
errors: shippingRule.getErrors('baseRate'),
required: true,
}) }}
{{ commerceForms.numberField({
label: "Minimum Total Shipping Cost"|t('commerce'),
name: 'minRate',
instructions: "The minimum the customer should spend on shipping. Set to zero to disable."|t('commerce'),
value: shippingRule.minRate,
type: 'number',
min: 0,
step: 'any',
errors: shippingRule.getErrors('minRate'),
required: true,
}) }}
{{ commerceForms.numberField({
label: "Maximum Total Shipping Cost"|t('commerce'),
instructions: "The maximum the customer should spend on shipping. Set to zero to disable."|t('commerce'),
name: 'maxRate',
value: shippingRule.maxRate,
type: 'number',
min: 0,
step: 'any',
errors: shippingRule.getErrors('maxRate'),
required: true,
}) }}
{{ "Item Rates"|t('commerce') }}
{% set shippingCategories = craft.commerce.shippingCategories.allShippingCategories %}
{% if shippingCategories %}