Module Dependency Map
CARRIER MODULES
+-------+-------+-------+-------+-------+
| | | | | |
v v v v v v
+-----+ +-----+ +-----+ +-----+ +------+ +--------+
| UPS | |USPS | |FedEx| | DHL | |Offline| |Inventory|
+--+--+ +--+--+ +--+--+ +--+--+ |Shipping| |Shipping|
| | | | +---+----+ +---+----+
| | | | | |
+-------+-------+-------+--------+----------+
|
v
+-----------------------+
| Magento_Shipping |
| (Carrier Framework) |
+-----------+-----------+
|
+---------------+---------------+
| | |
v v v
+----------+ +-----------+ +----------+
| Quote | | Sales | | Checkout |
| (Rates) | | (Shipment)| | (Display)|
+----+-----+ +-----+-----+ +----+-----+
| | |
v v v
+----------+ +-----------+ +----------+
| Customer | | Order | | Payment |
| Address | | Tracking | | Info |
+----------+ +-----------+ +----------+
DEPENDENCIES (module.xml sequence):
+-----------------------------------------------+
| Magento_Shipping depends on: |
| - Magento_Store |
| - Magento_Catalog |
| - Magento_Ui |
| - Magento_User |
+-----------------------------------------------+
Quote Module Integration
The Quote module is the primary consumer of shipping rate collection. During checkout, the quote address triggers rate collection through the RateCollectorInterface.
Integration Points
| Quote Class | Shipping Class | Purpose |
|---|---|---|
| Quote\Model\Quote\ Address |
Model\Shipping | Collects rates via RateCollectorInterface |
| Quote\Model\Quote\ Address\RateRequest |
Model\Carrier\ AbstractCarrier |
Request object passed to carriers |
| Quote\Model\Quote\ Address\Rate |
Model\Rate\Result\ Method |
Individual shipping method result |
Rate Request Data Flow
// Quote\Model\Quote\Address::collectShippingRates() $request = $this->rateRequestFactory->create(); // Request contains: $request->setAllItems($this->getAllItems()); $request->setDestCountryId($this->getCountryId()); $request->setDestRegionId($this->getRegionId()); $request->setDestPostcode($this->getPostcode()); $request->setPackageValue($this->getBaseSubtotal()); $request->setPackageWeight($this->getWeight()); $request->setPackageQty($this->getItemQty()); $request->setStoreId($this->getQuote()->getStore()->getId()); // Collect rates via shipping module $result = $this->rateCollector->collectRates($request)->getResult();
Sales Module Integration
The Sales module handles order shipments. Shipping provides controllers and blocks for shipment management in the admin area.
Shipment-Related Tables
| Table | Purpose | Key Fields |
|---|---|---|
| sales_shipment | Shipment records | entity_id, order_id, shipping_label |
| sales_shipment_item | Items in shipment | entity_id, parent_id, sku, qty |
| sales_shipment_track | Tracking numbers | entity_id, parent_id, track_number, carrier_code |
| sales_shipment_comment | Shipment comments | entity_id, parent_id, comment |
| sales_shipping_ aggregated_order |
Aggregated report data | period, store_id, shipping_description, total_qty |
Admin Controllers
Controller\Adminhtml\Order\Shipment\
- NewAction - Create shipment form
- Save - Save shipment
- View - View shipment details
- AddTrack - Add tracking number
- RemoveTrack - Remove tracking
- CreateLabel - Generate label
- PrintLabel - Print label
- Email - Send shipment email
Mass Actions
- Pdfshipments - Generate PDF
- MassPrintShippingLabel - Bulk label print
- PrintPackage - Print package info
Carrier Module Integration
Each carrier module extends the shipping framework by registering a carrier model and implementing the required interfaces.
Core Carrier Modules
| Module | Carrier Code | Base Class | Features |
|---|---|---|---|
| Magento_Ups | ups | AbstractCarrierOnline | Rates, Tracking, Labels |
| Magento_Usps | usps | AbstractCarrierOnline | Rates, Tracking, Labels |
| Magento_Fedex | fedex | AbstractCarrierOnline | Rates, Tracking, Labels |
| Magento_Dhl | dhl | AbstractCarrierOnline | Rates, Tracking, Labels |
| Magento_Offline Shipping |
flatrate, tablerate, freeshipping |
AbstractCarrier | Rates only |
Carrier Registration Pattern
<!-- module-ups/etc/config.xml -->
<config>
<default>
<carriers>
<ups>
<active>0</active>
<model>Magento\Ups\Model\Carrier</model>
<title>United Parcel Service</title>
<sallowspecific>0</sallowspecific>
<allowed_methods>1DA,2DA,3DS,GND,STD,...</allowed_methods>
<free_method>GND</free_method>
<shipment_requesttype>0</shipment_requesttype>
<max_package_weight>150</max_package_weight>
<showmethod>0</showmethod>
<!-- ... additional config ... -->
</ups>
</carriers>
</default>
</config>
Checkout Integration
During checkout, shipping rates are displayed for customer selection. The integration flows through the Quote module's shipping address.
Checkout Flow
CHECKOUT SHIPPING STEP
======================
+----------------------------------+
| Customer enters shipping address |
+----------------+-----------------+
|
v
+----------------------------------+
| JS: estimate-shipping-methods |
| API endpoint |
+----------------+-----------------+
|
v
+----------------------------------+
| Quote\Model\ShippingMethod |
| ManagementInterface |
| ::estimateByAddress() |
+----------------+-----------------+
|
v
+----------------------------------+
| Quote\Model\Quote\Address |
| ::collectShippingRates() |
+----------------+-----------------+
|
v
+----------------------------------+
| Shipping\Model\Shipping |
| ::collectRates() |
+----------------+-----------------+
|
v
+----------------------------------+
| Return array of |
| ShippingMethodInterface |
+----------------+-----------------+
|
v
+----------------------------------+
| Display shipping methods as |
| radio buttons in checkout |
+----------------------------------+
REST API Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
| /V1/carts/:cartId/ estimate-shipping-methods |
POST | Estimate shipping for logged-in customer |
| /V1/guest-carts/:cartId/ estimate-shipping-methods |
POST | Estimate shipping for guest |
| /V1/carts/:cartId/ shipping-information |
POST | Set shipping address and method |
Multi-Source Inventory (MSI) Integration
When MSI is enabled, the shipping module integrates with inventory source selection during shipment creation.
MSI Modules
| Module | Integration Type | Purpose |
|---|---|---|
| InventoryShipping | Preference | Overrides shipment creation for source selection |
| InventoryShippingAdminUi | Plugin | Modifies admin UI for source selection |
| InventoryInStorePickup ShippingAdminUi |
Plugin | Adds store pickup tracking features |
MSI Controller Override
When MSI is installed, Controller\Adminhtml\Order\Shipment\NewAction
is replaced with InventoryShipping\Controller\...\NewAction
via DI preference. This enables source selection during shipment creation.
Events Related to Shipping
While Magento_Shipping doesn't define its own events, it integrates with Sales module events:
| Event | Source Module | Shipping Relevance |
|---|---|---|
| sales_order_shipment_ save_before |
Sales | Modify shipment before save |
| sales_order_shipment_ save_after |
Sales | Post-shipment processing (emails, inventory) |
| sales_order_place_after | Sales | Shipping method selected with order |