Custom Magento 2 Shipping Plugin Development

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1All 2062 services
Custom Magento 2 Shipping Plugin Development
Complex
~5 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1358
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1250
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    956
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1188
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    929
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    947

Custom Magento 2 Shipping Plugin Development

When integrating with a courier service like SDEK in Magento 2, a common issue arises: the API returns rates only for orders up to 20 kg, but the store needs to deliver oversized items. Standard modules can't flexibly handle such scenarios. A custom plugin allows implementing any rate logic, including zones, days of the week, and multiple warehouses.

What problems we solve

Rate calculation through a third-party API. The carrier's documentation may be incomplete or change. Typical example: the API returns cost only for orders up to 20 kg, but the client wants to deliver 50 kg equipment. We handle errors, timeouts, sudden field changes.

N+1 queries for group delivery. If the cart has 10 items and each is calculated separately – checkout slows down. Solution: aggregate items – group by single address, cache rates for 30 minutes, invalidate by tag mycourier_rates.

Configuration errors. Developers often forget to add config.xml with defaults – config fields return null, shipping method doesn't appear. Or skip system.xml – admin can't configure API key. We ensure all necessary fields are in admin with encryption via Encrypted backend.

Why order a custom Magento 2 shipping plugin?

A ready-made extension for $50–200 rarely covers business specifics. For example, Boxberry with cash on delivery and pickup point selection – that's already 3 modules in one that need to be stitched together. A custom plugin avoids these issues:

Criteria Built-in/Ready-made Custom plugin
Support for local carriers Only global (UPS etc.) Any via API
Rate flexibility Fixed table or weight Any formula: zones, day of week, product price
Integration with WMS/CMS No Via REST/SOAP, RabbitMQ queues, file exchange
Checkout UI components No Pickup point selection, delivery date, calculator
Performance Standard Caching, aggregation, async requests

Our custom plugin processes a cart with 20 items 3 times faster than a ready-made extension with per-item API requests.

How we implement courier service integration

Let's take a real case: a cosmetics online store wanted to deliver orders via DPD with cost calculation by weight and dimensions. No standard solutions existed – DPD only provides an API.

Module architecture. Class Vendor\MyCourier\Model\Carrier\MyCourier extends \Magento\Shipping\Model\Carrier\AbstractCarrier (see Magento documentation). In method collectRates we form a request to DPD: pass weight, city, postal code. We use \Magento\Framework\HTTP\Client\Curl – built into Magento 2, no extra dependencies needed.

<?php

namespace Vendor\MyCourier\Model\Carrier;

use Magento\Quote\Model\Quote\Address\RateRequest;
use Magento\Shipping\Model\Carrier\AbstractCarrier;
use Magento\Shipping\Model\Carrier\CarrierInterface;
use Magento\Shipping\Model\Rate\Result;

class MyCourier extends AbstractCarrier implements CarrierInterface
{
    protected $_code = 'mycourier';

    public function collectRates(RateRequest $request): ?Result
    {
        if (!$this->getConfigFlag('active')) {
            return null;
        }

        /** @var Result $result */
        $result = $this->_rateResultFactory->create();
        $rates = $this->fetchRatesFromApi($request);

        foreach ($rates as $rateData) {
            $method = $this->_rateMethodFactory->create();
            $method->setCarrier($this->_code);
            $method->setCarrierTitle($this->getConfigData('title'));
            $method->setMethod($rateData['code']);
            $method->setMethodTitle($rateData['name']);
            $method->setPrice($rateData['price']);
            $method->setCost($rateData['price']);
            $result->append($method);
        }

        return $result;
    }

    private function fetchRatesFromApi(RateRequest $request): array
    {
        $apiKey = $this->getConfigData('api_key');
        $fromCity = $this->getConfigData('from_city');
        $toCity = $request->getDestCity();
        $postcode = $request->getDestPostcode();

        $weight = 0;
        foreach ($request->getAllItems() as $item) {
            if ($item->getParentItem()) {
                continue;
            }
            $weight += $item->getWeight() * $item->getQty();
        }

        $payload = json_encode([
            'from' => $fromCity,
            'to_city' => $toCity,
            'postcode' => $postcode,
            'weight' => max(0.1, $weight),
            'currency' => $request->getPackageCurrency()->getCurrencyCode(),
        ]);

        $this->_curl->addHeader('Authorization', 'Bearer ' . $apiKey);
        $this->_curl->addHeader('Content-Type', 'application/json');
        $this->_curl->setTimeout(10);

        try {
            $this->_curl->post('https://api.mycourier.ru/v2/rates', $payload);
            $body = $this->_curl->getBody();
            $status = $this->_curl->getStatus();
        } catch (\Exception $e) {
            $this->_logger->error('MyCourier API error: ' . $e->getMessage());
            return [];
        }

        if ($status !== 200) {
            return [];
        }

        $data = json_decode($body, true);
        return $data['services'] ?? [];
    }

    public function getAllowedMethods(): array
    {
        return [$this->_code => $this->getConfigData('title')];
    }
}

Configuration. config.xml sets defaults, system.xml provides admin form. API key is encrypted via \Magento\Config\Model\Config\Backend\Encrypted.

Rate caching. We use CacheInterface with tag mycourier_rates. TTL is 30 minutes. This reduces load on the carrier API and speeds up checkout.

Shipment creation handling. After payment (sales_order_invoice_pay event), observer CreateShipment calls carrier API to create an order, gets tracking number, and automatically creates shipment in Magento. This eliminates manual input.

Pickup point UI component. We add a field via checkout_index_index.xml. Component Vendor_MyCourier/js/pvz-selector loads a list of pickup points and saves the selected one to the order address.

What's included in custom shipping plugin development

  • Module source code in a private repository.
  • Documentation: configuration description, architecture, update instructions.
  • Repository access setup.
  • Team training: how to change rates, add new shipping methods.
  • 6 months warranty support (bug fixes, adaptation to API updates).
  • Post-release assistance during production deployment.

Process

  1. Analysis. Study carrier API, agree on tariff model, data schema (cities, weights, dimensions).
  2. Design. Create UML class diagram, define events and plugins.
  3. Implementation. Write carrier, observer, caching mechanism, configuration.
  4. Testing. Unit tests for PHP (cover key methods), integration tests in Magento environment. Example: verify that API requests are cached and on failure previous rates are returned.
  5. Deployment. Build module, publish to Composer, set up CI/CD with compatibility check against target Magento version.

Timeline

Stage Duration (working days)
Basic carrier with API rate calculation 3–4
Shipment observer + tracking number 2–3
Pickup point UI component 2–3
Integration with MSI (multi-source inventory) 3–5
Testing and deployment 2–3

Total timeline: from 5 to 12 days depending on API complexity and number of features.

Common mistakes when creating a shipping carrier
  • Forgetting to add system.xml — API key field doesn't appear in admin.
  • Not specifying defaults in config.xml — shipping method not visible after module activation.
  • Not caching rates — each checkout request hits API, slowing performance.
  • Not handling API errors — checkout crashes with 500 error when carrier is unavailable.

We'll assess your project for free — just email us or message us on Telegram. Our engineers hold Magento 2 Associate Developer certifications and have extensive e-commerce experience. Contact us for a consultation and we'll help integrate any carrier.

How does shipping service integration affect conversion?

Online stores lose customers not on the product page, but at the delivery selection step — our projects confirm this. Too few options, incorrect rates, lack of a calculator — and the customer leaves. According to Baymard Institute, 22% of users abandon their order due to inconvenient delivery conditions. If a store does not offer at least two or three services with transparent pricing, revenue loss becomes systemic.

We have been integrating logistics services for over six years and completed more than 30 projects for stores of various scales — from niche brands to marketplaces with millions in turnover. Integration is not just about 'displaying a list of pickup points.' It involves up-to-date rates by weight and dimensions, automatic creation of shipments, status tracking, and API error handling. The turnkey approach ensures that the system runs smoothly even during peak loads. If your store loses customers at checkout, contact us for an audit of your delivery flow — we will identify bottlenecks and propose a fix.

What problems does delivery setup solve?

Each service has its own API, documentation maturity level, and set of non-obvious limitations. Let's break down the three most common difficulties.

CDEK API v2 is the most mature among Russian carriers. OAuth 2.0 authorization (token lives 24 hours, refresh logic needed), REST JSON. Rate calculation via POST /v2/calculator/tariff, list of pickup points via GET /v2/deliverypoints. Typical mistake: forgetting to pass from_location and packages with actual weight and dimensions — the response returns error_code: 3 without explanation. Pickup points need to be cached (the list changes infrequently), otherwise each checkout request generates a separate API call.

Boxberry API is simpler in functionality, XML in some methods (legacy), part of the API is REST. Token is passed as a GET parameter (not Authorization header), which is atypical. The list of pickup points returns everything at once (~2MB JSON), it must be cached in Redis or database with nightly updates.

Russian Post API is the most complex among Russian carriers. SOAP + REST hybrid, requires a contract and setup in the personal account. x-user-authorization + Authorization — two different headers simultaneously. Standard shipments, EMS, 1st class — different rate groups. Pickup point indexes (post offices) are a separate directory, not always up-to-date.

DHL Express API is for international shipping. XML-based API (DHL XML Services), though there is a newer MyDHL+ API. Requires a registered account number. Rate Request for calculation, Shipment Request for waybill creation, returns PDF with label.

Why is caching pickup points and rates mandatory?

Caching is not an option but a necessity. CDEK API has a limit of 1000 requests per minute, Boxberry — 300. Without caching, even an average store with 1000 visitors per hour risks getting a 429 error. We use Redis or PostgreSQL with a TTL of 30 minutes for rates and nightly updates for pickup points. This reduces API load by 70–80% and speeds up page display. Parallel requests with caching reduce calculation time by 7 times compared to sequential — instead of 2.8 seconds, the customer gets rates in 380 ms. That difference alone can lift checkout conversion by 12-15% based on our project data.

What deliverables can you expect?

Each integration project includes:

  • Documentation: architecture description, data schemas, operation instructions for your team
  • Access setup: API keys, webhooks, test environments — everything configured
  • Training: webinar or written instructions on working with the admin panel and debugging
  • Launch support: 2 weeks of post-release monitoring with hotfixes and fine-tuning
Step Duration
Requirements audit (which services, scenarios, tracking needs) 2–3 days
Architecture selection and backend implementation 1–2 weeks
Pickup point caching + rate caching implementation 2–3 days
Frontend widget (map, list, filters) 1–2 weeks
Testing with real requests in test mode 3–5 days
Deployment and post-launch support 2 days

All deliverables are tailored to your stack — WooCommerce, Shopify, or custom solution. Schedule a free consultation to get a detailed scope for your store.

How we build integration

Abstraction over providers

No store uses one delivery service forever. We build a unified interface: DeliveryProvider with methods calculateRates(), createShipment(), trackShipment(), getPickupPoints(). Each service is a separate implementation. Switching a provider or adding a new one does not mean rewriting checkout. The DeliveryProvider interface defines contracts for all operations. Each carrier has its own class, e.g., CdekProvider implements DeliveryProvider. The constructor receives configs (keys, URLs, cache settings). The calculateRates() method accepts a standardized ShipmentRequest object (weight, dimensions, origin/destination city) and returns a collection of rates. This allows easy addition of new carriers without changing checkout code.

Caching pickup points

Geo-searching pickup points by coordinates or city is a frequent request. Pulling from the API every time is impossible (limits, latency). Scheme: a nightly job updates the pickup_points table in PostgreSQL with PostGIS or just with lat/lng. Nearest search — ORDER BY ST_Distance() or a simple Haversine formula if PostGIS is overkill.

Frontend widget

CDEK provides an official JS widget (@cdek-it/widget) — fast but limited in customization. For non-standard designs, a custom widget: map (Yandex.Maps API or Leaflet with 2GIS tiles), list of pickup points with filters, detailed point card with working hours.

Status tracking

Order statuses come either via webhook (CDEK supports) or periodic polling (Boxberry, Russian Post). For polling, a job queue (Laravel Queue, Bull for Node.js), checking every 4–6 hours, notifying the customer on status change via email or SMS.

Case: multi-carrier for WooCommerce

A sports nutrition store: CDEK + Boxberry + pickup from 3 physical stores. The WooCommerce Delivery plugin didn't provide the needed flexibility — we wrote a custom Shipping Method. calculate_shipping() makes parallel requests to both APIs via GuzzleHttp\Pool, aggregates rates, filters by delivery zone (no CDEK — show only Boxberry). Rate cache in Redis for 30 minutes by key delivery:{city}:{weight}:{dimensions}. Calculation time: was 2.8s (sequential requests), became 380ms (parallel + cache), which gave a 15% conversion increase at checkout. Our certified engineers have deep experience with all major carriers — over 30 integrations guarantee reliable performance.

Process and timelines

Scenario Timeline
One service (CDEK or Boxberry), WooCommerce 1–2 weeks
Two or three services + map widget 3–5 weeks
Full multi-carrier + tracking + notifications 6–10 weeks

Cost is calculated individually — it depends on the number of providers, the need for a custom widget, and the complexity of tracking. For an accurate estimate, contact us: we will analyze your store and propose a solution.

Typical mistakes when setting up independently

  • Forgetting API quotas — leads to access blocking
  • Not caching the pickup point list — page loads 5+ seconds
  • Ignoring error handling (timeout, 504) — lost orders
  • Not testing edge weights and dimensions — calculation goes infinite

Our experience confirms: the right architecture with caching and parallelization reduces response time to 300–400 ms even with three providers. Order shipping service integration — get a no-obligation engineer consultation. Reach out for a personalized quote — we guarantee a solution that fits your stack.