Skip to content
  1. Extras
  2. MiniShop3
  3. Manager interface
  4. Settings
  5. Deliveries

Delivery methods

Delivery method management is available via Extras → MiniShop3 → Settings → Deliveries.

Delivery fields

FieldTypeDescription
namestringDelivery method name
descriptiontextDescription for customer
pricenumberBase delivery cost
weight_pricefloatCost per weight unit
distance_pricefloatCost per distance unit
free_delivery_amountfloatOrder amount for free delivery
logostringImage path
positionintSort order
activeboolActive
classstringPHP handler class
validation_rulesJSONField validation rules

Payment association

Each delivery method can be linked to specific payment methods. This allows:

  • Restricting cash payment to pickup only
  • Allowing online payment for courier delivery
  • Configuring specific combinations for different regions

When the customer selects a delivery method, the list of available payment methods is filtered automatically.

Cost calculation

Delivery cost is calculated as:

Total cost = price + (weight_price × weight) + (distance_price × distance)

If the order total exceeds free_delivery_amount, delivery cost = 0.

Custom calculation

For complex logic, create your own handler class:

php
<?php
namespace MyComponent\Delivery;

use MiniShop3\Controllers\Delivery\DeliveryProviderInterface;
use MiniShop3\Model\msDelivery;
use MiniShop3\Model\msOrder;

class CustomDelivery implements DeliveryProviderInterface
{
    public function getCost(msDelivery $delivery, msOrder $order, float $cost): float
    {
        $cartCost = $order->get('cart_cost');
        $weight = $order->get('weight');

        if ($cartCost > 10000) {
            return 0; // Free over 10000
        }

        if ($weight > 5000) {
            return 500 + ($weight - 5000) * 0.1; // Surcharge for heavy orders
        }

        return 300; // Base cost
    }
}

Specify the class in the class field: MyComponent\Delivery\CustomDelivery

Order field validation

MiniShop3 lets you configure required fields and validation rules per delivery method. For example, courier delivery can require a full address, while pickup may require only a phone number.

Visual builder

The validation settings interface has two modes:

Visual mode

Intuitive rule builder:

  1. Click Add field
  2. Select a field from the list (grouped: Order, Address)
  3. Add validation rules for the field
  4. For rules with parameters, enter the value

Rules are shown as chips that can be removed by clicking the cross.

JSON mode

A switch lets you edit JSON manually:

json
{
  "phone": "required",
  "email": "required|email",
  "city": "required|min:2",
  "street": "required|min:3",
  "building": "required"
}

Useful for:

  • Copying rules between deliveries
  • Complex rules with regular expressions
  • Import/export of configuration

Custom validation fields

Besides standard order and address fields, you can add arbitrary fields with validation rules — for example, an agreement checkbox:

json
{
  "phone": "required",
  "email": "required|email",
  "agreement": "required|accepted"
}

Custom fields (agreement and others outside the standard set) are kept in the order draft between order/add and order/submit. When the order is created they are passed to msOnBeforeCreateOrder / msOnCreateOrder via customFields.

Checkboxes

On the frontend, checkboxes send input.checked ('1' or '0'), not the static value attribute. This is required for the accepted rule to work correctly.

Fields available for validation

Order fields

FieldDescription
order_commentOrder comment

Address fields

FieldDescription
first_nameFirst name
last_nameLast name
phonePhone
emailEmail
countryCountry
indexPostal code
regionRegion/state
cityCity
metroMetro station
streetStreet
buildingBuilding
entranceEntrance
floorFloor
roomApartment/office
commentAddress comment
text_addressFull address as text

Validation rules

MiniShop3 uses rakit/validation for validation.

Basic rules

RuleDescriptionExample
requiredRequired fieldrequired
nullableField may be nullnullable
presentField must be present (even if empty)present
acceptedValue must be "yes", "on", "1", trueaccepted

Data types

RuleDescriptionExample
emailValid emailemail
urlValid URLurl
ipIP address (v4 or v6)ip
ipv4IPv4 addressipv4
ipv6IPv6 addressipv6
numericNumeric valuenumeric
integerIntegerinteger
booleanBooleanboolean
arrayArrayarray
jsonValid JSONjson

String rules

RuleDescriptionExample
alphaLetters onlyalpha
alpha_numLetters and digitsalpha_num
alpha_dashLetters, digits, dash, underscorealpha_dash
alpha_spacesLetters and spacesalpha_spaces
uppercaseUppercase onlyuppercase
lowercaseLowercase onlylowercase

Parameterized rules

RuleDescriptionSyntax
minMin string length or number valuemin:3
maxMax string length or number valuemax:100
betweenValue in rangebetween:1,10
digitsExact digit countdigits:6
digits_betweenDigit count in rangedigits_between:4,8
inValue from listin:pickup,courier,post
not_inValue not in listnot_in:test,demo
sameMust match another fieldsame:email_confirm
differentMust differ from another fielddifferent:old_password
regexMatches regular expressionregex:/^[0-9]{6}$/

Date rules

RuleDescriptionSyntax
dateValid date in formatdate:Y-m-d
afterDate after givenafter:2024-01-01
beforeDate before givenbefore:2025-12-31

Conditional rules

RuleDescriptionSyntax
required_ifRequired if another field equals valuerequired_if:delivery,courier
required_unlessRequired unless another field equals valuerequired_unless:delivery,pickup
required_withRequired if another field is presentrequired_with:phone
required_withoutRequired if another field is absentrequired_without:email
required_with_allRequired if all listed fields are presentrequired_with_all:city,street
required_without_allRequired if none of the listed fields are presentrequired_without_all:phone,email

Example configurations

Courier delivery

Full address required:

json
{
  "first_name": "required|min:2",
  "last_name": "required|min:2",
  "phone": "required|regex:/^\\+?[0-9]{10,15}$/",
  "email": "required|email",
  "city": "required|min:2",
  "street": "required|min:3",
  "building": "required",
  "room": "required_if:building_type,apartment"
}

Pickup

Minimum contact data:

json
{
  "first_name": "required|min:2",
  "phone": "required"
}

Postal delivery

Postal code and full address required:

json
{
  "first_name": "required",
  "last_name": "required",
  "phone": "required",
  "index": "required|digits:6",
  "region": "required",
  "city": "required",
  "street": "required",
  "building": "required"
}

Parcel locker

Contact details only:

json
{
  "first_name": "required",
  "phone": "required|regex:/^\\+?[0-9]{10,15}$/",
  "email": "required|email"
}

Combining rules

Rules are combined with |:

json
{
  "email": "required|email",
  "phone": "required|numeric|min:10|max:15",
  "index": "nullable|digits:6"
}

Error messages

The validator generates error messages in the interface language. The user sees clear messages such as:

  • "Email field is required"
  • "Phone field must be at least 10 characters"
  • "Index field must be 6 digits"

API

Get validation rules

GET /api/v1/order/delivery/validation-rules?delivery_id=1

Response:

json
{
  "success": true,
  "data": {
    "phone": "required",
    "city": "required|min:2",
    "street": "required"
  }
}

Get required fields

GET /api/v1/order/delivery/required-fields?delivery_id=1

Response:

json
{
  "success": true,
  "data": ["phone", "city", "street"]
}

Use these endpoints to update the order form dynamically when the delivery method changes.