I would like to create a custom shipping module. As per my understanding a custom shipping module is created for single carrier. Am i correct ?
Is it possible manage multiple carriers using a single custom module? Or do i have to create different modules for each of the carriers? If i have to create different custom module for each of the carriers, then is it possible to write a function that executes before the code for each of the carriers are executed?
My aim is to do some validation and pick the carriers based on the validations result. For example i need to identify if carrier will ship a particular type of product. If they will carry that product, check whether they have pickup from seller location and delivery at the customers location. If its passes both this validation then include them in the results or otherwise remove it from the rest of the process.
Best Answer
If you want to add multiple shipping carriers, you need to setup the normal configuration: app/code/YourPackage/YourModule/etc/config.xml
In your system.xml app/code/YourPackage/YourModule/etc/system.xml Please note the "source_model" tag. You need to define this class in your module as well.
Then, in your source model: YourPackage_YourModule_Model_Shipping_Source_Method (Note, this class no needs to extend any class, you just need the method: toOptionArray)
Then, in your carrier model: YourPackage_YourModule_Model_Carrier_YourCarrier
This way, when you enable this carrier from the System Configuration, it will show all methods (carriers) that are enabled as radio buttons on checkout, but they will also be shown in the Promotions rules, so you can setup different promotions depending on the shipping carrier.