PHASE 1 CORE COMMERCE

Magento_Shipping

Carrier abstraction layer, rate calculation, and shipment management for the Magento ecommerce platform.

104
PHP Classes
19
Controllers
36
Models
18
Blocks
1
Cron Job

Module Overview

The Magento_Shipping module provides the carrier abstraction layer that enables flexible shipping rate calculation and shipment management. It defines the base classes and interfaces that all shipping carriers (UPS, FedEx, USPS, etc.) must implement to integrate with Magento's checkout and order fulfillment workflows.

Key Responsibilities

  • Rate collection from multiple carriers
  • Shipment creation and tracking
  • Shipping label generation
  • Package weight and dimension calculations
  • Carrier factory and configuration

What This Module Does NOT Do

  • Implement specific carrier APIs (see UPS, FedEx, USPS modules)
  • Handle payment processing
  • Manage inventory reservations (see InventoryShipping)
  • Define table rate rules (see OfflineShipping)

Core Classes

Carrier\AbstractCarrier

Model/Carrier/AbstractCarrier.php

Base class for all shipping carriers. Provides configuration access, rate calculation framework, and handling fee logic.

Carrier\AbstractCarrierOnline

Model/Carrier/AbstractCarrierOnline.php

Extended base for carriers requiring API calls. Adds shipping labels, tracking, container types, and delivery confirmation.

Shipping

Model/Shipping.php

Main rate collection orchestrator. Iterates through enabled carriers, collects rates, and aggregates results into a single response.

CarrierFactory

Model/CarrierFactory.php

Factory class for instantiating carrier models based on carrier code and store configuration.

Tracking\Result

Model/Tracking/Result.php

Container for tracking information collected from carrier APIs. Used by the tracking popup and shipment view.

Shipping\Labels

Model/Shipping/Labels.php

Extends Shipping for admin area. Adds shipping label creation functionality for supported carriers.

Carrier Interface Contract

All carriers must implement AbstractCarrierInterface:

interface AbstractCarrierInterface
{
    // Core rate methods
    public function collectRates(RateRequest $request);
    public function getConfigData($field);

    // Shipment operations
    public function requestToShipment($request);
    public function returnOfShipment($request);

    // Carrier capabilities
    public function isActive();
    public function isTrackingAvailable();
    public function isShippingLabelsAvailable();

    // Container/packaging
    public function getContainerTypes($params = null);
    public function getDeliveryConfirmationTypes($params = null);

    // Validation
    public function checkAvailableShipCountries($request);
    public function proccessAdditionalValidation($request);

    // Pricing
    public function getFinalPriceWithHandlingFee($cost);
    public function getTotalNumOfBoxes($weight);
}

Configuration

Admin Configuration Paths

Path Description
shipping/origin/* Store origin address (country, region, postal code)
shipping/shipping_policy/* Custom shipping policy text displayed at checkout
carriers/[code]/active Enable/disable specific carrier
carriers/[code]/title Carrier display name at checkout
carriers/[code]/sallowspecific Ship to all or specific countries

Documentation

Module Dependencies

Required By (sequence)

  • Magento_Store
  • Magento_Catalog
  • Magento_Ui
  • Magento_User

Dependent Carrier Modules

  • Magento_Ups
  • Magento_Usps
  • Magento_Fedex
  • Magento_Dhl
  • Magento_OfflineShipping

Quick Reference

Key Files

  • Model/Carrier/AbstractCarrier.php
  • Model/Carrier/AbstractCarrierOnline.php
  • Model/Shipping.php
  • Model/CarrierFactory.php
  • etc/di.xml
  • etc/adminhtml/system.xml

Cron Jobs

Job Schedule
aggregate_sales_report_shipment_data Daily at midnight

Logging

Carrier debug output writes to var/log/shipping.log via the VirtualLogger configured in di.xml.