How to create custom shipping like DHL, UPS, … in magento 2 so I will be able to connect to third party API and get all the data to create package, tracking numbers and labels? Is there any skeleton Carrier class how to do such thing?
Magento – How to programmaticlly create custom shipping method for third party API
magento2shipping
Best Answer
In the Magento, shipping carriers divided into two types: online and offline shipping.
They should implement
\Magento\Shipping\Model\Carrier\CarrierInterface
:isTrackingAvailable()
getAllowedMethods()
1) For the offline shipping, your custom shipping simply extends from Abstract carrier model-
\Magento\Shipping\Model\Carrier\AbstractCarrier
.A good sample here: https://github.com/ajzele/B05032-Foggyline_Shipbox
2) For the online shipping, your module should extends from the abstract online shipping carrier model -
Magento\Shipping\Model\Carrier\AbstractCarrierOnline
.We should take a look the USPS shipping or DHL International:
-
vendor/magento/module-usps/Model/Carrier.php
-
vendor/magento/module-dhl/Model/Carrier.php