How to add shipping methods in Magento?

When a set of available methods of delivery (shipping methods) in Magento is not enough for our needs and we would like to add custom methods, we can relatively easily do this by creating our own extension. Each new delivery method can be implemented either as a separate module or as one module with any number of methods. For example, let’s add a concierge service as a new way of delivery.

The implementation has to start with creating your own extensions (this step is omitted here – I assume that a reader knows how to create Magento extensions). Our module’s name will be NewShippingMethods and we will define concierge as a new method of delivery. We will need a model definition in the config.xml file:

At this point, we create a Model/Carrier/Concierge.php. Once we have class created in it, it should:

– inherit from an abstract class Mage_Shipping_Model_Carrier_Abstract

– implement the Mage_Shipping_Model_Carrier_Interface interface

We add the method code (ID) – it can only contain letters a-z, digits 0-9 and the character _:

Now it is time for the implementation of the most important method – collectRates (). In order to make it more simple, we assume that the service is free (of course you can implement any kind of logic for calculating cost):

Make sure that the method is active (of course you should add the option in the files config.xml and system.xml).

We collect two objects – the first one will be returned by our method, the second will contain details on shipping method:

We have to set the code, header and name:

We set the price and cost:

We add our method to the collection and we return:

Now we only have to implement the method getAllowedMethods(), which returns an array of available methods:

For the full functionality, it is necessary to add the configuration options of delivery method in the files config.xml and system.xml.

Good luck! 🙂