I had to create a custom shipping méthod with some conditions to be valid. I need a validation step during my checkout, and I found a method without override Magento core.

In your config.xml, add the following observer :

<?xml version="1.0"?>
    <!-- ... -->
        <!-- ... -->
			<!-- ... -->
			<!-- ... -->
        <!-- ... -->
	<!-- ... -->

And in the Observer’s class (/app/code/local/Mypackage/Mymodule/Model/Checkout/ShippingMethod/Observer.php) :


class Mypackage_Mymodule_Model_Checkout_ShippingMethod_Observer
	public function myMethod($observer)
		/* Your logic */
			$message = Mage::helper('mymodule')->__('Your error message');
			$result = array('error' => 1, 'message' => $message);
			$controllerAction = $observer->getEvent()->getControllerAction();
		return $this

You will have an error message in the checkout, and the visitor need to have no error to continue.

Add validation on a custom shipping method
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *

We use cookies to ensure that we give you the best experience on our website.