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

Delivery methods ​

Delivery methods are managed via Extras → MiniShop3 → Settings → Deliveries.

Delivery fields ​

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

Payment linkage ​

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

  • Restrict cash payment to pickup only
  • Allow online payment for courier delivery
  • Configure specific combinations for different regions

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

Cost calculation ​

Delivery cost is calculated with:

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 a custom 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
    {
        // Your calculation logic
        $cartCost = $order->get('cart_cost');
        $weight = $order->get('weight');

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

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

        return 300; // Base cost
    }
}

Set the class in class: MyComponent\Delivery\CustomDelivery

Order field validation ​

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

Visual builder ​

The validation setup interface offers 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, set the value

Rules appear as tags (chips) you can remove with the close icon.

JSON mode ​

A toggle switches to manual JSON editing:

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 stored in the order draft between order/add and order/submit steps. When the order is created they are passed to msOnBeforeCreateOrder / msOnCreateOrder via the customFields parameter.

Checkboxes

On the frontend, checkboxes send input.checked ('1' or '0'), not a static value attribute. This ensures the accepted rule works correctly.

Available validation fields ​

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 the rakit/validation library.

Basic rules ​

RuleDescriptionExample
requiredRequired fieldrequired
nullableField may be nullnullable
presentField must be present (even 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

Rules with parameters ​

RuleDescriptionSyntax
minMin string length or numeric valuemin:3
maxMax string length or numeric 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 from listnot_in:test,demo
sameMatches another fieldsame:email_confirm
differentDiffers from another fielddifferent:old_password
regexMatches regular expressionregex:/^[0-9]{6}$/

Date rules ​

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

Conditional rules ​

RuleDescriptionSyntax
required_ifRequired if another field equals valuerequired_if:delivery,courier
required_unlessRequired if another field ≠ valuerequired_unless:delivery,pickup
required_withRequired if another field is setrequired_with:phone
required_withoutRequired if another field is NOT setrequired_without:email
required_with_allRequired if ALL fields are setrequired_with_all:city,street
required_without_allRequired if NONE of the fields are setrequired_without_all:phone,email

Configuration examples ​

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 delivery ​

Contact data only:

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

Combining rules ​

Combine rules 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 messages such as:

  • "The Email field is required"
  • "The Phone field must be at least 10 characters"
  • "The 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.