My requirement is when the shopping cart page is loaded i need to set my custom shipping rate and show it on the cart page.I have country name and shipping price in my hand.The shipping method is matrix rate.I have tried the estimate shipping method box functionality on the page load but it didn't work.

1 Answer 1


In order to set the default shipping at cart page, you can observe the event - sales_quote_collect_totals_before

Define your event-observer in app/code/local/MagePsycho/Autoshipping/etc/config.xml


And your Observer Model should look like:


 * @category   MagePsycho
 * @package    MagePsycho_Autoshipping
 * @author     Raj KB <[email protected]>
 * @website    http://www.magepsycho.com
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
class MagePsycho_Autoshipping_Model_Observer
    function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer)
        $quote = $observer->getEvent()->getQuote();
        if (!$quote->getId()) return;
        $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
        if ($shippingMethod) return;
        $shippingAddress = $quote->getShippingAddress();
        $country = 'US'; // Some country code
        $postcode = '1234'; // Some postcode
        $regionId = '1234'; // Some region id
        $method = 'your-custom-shipping-method-code'; // shipping method code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.