Magento setShippingMethod('freeshipping_freeshipping') observer event

1.3k views Asked by At

I need to display the shipping notice in cart. In order to display the notice I've set the shipping method using php in an observer:

$quote = Mage::getModel('checkout/cart')->getQuote();
$shippingAddress = $quote->getShippingAddress();
$shippingAddress->setCountryId('DE')->setShippingMethod('freeshipping_freeshipping')->save();

The event I used is "add_to_cart_before":

<add_to_cart_before>
    <observers>
        <add_to_cart_before>
            <class>dispatcher/observer</class>
            <method>hookToAddToCartBefore</method>
        </add_to_cart_before>
    </observers>
</add_to_cart_before>

The problem is that this event is fired after the shipping notice is read by magento. So in fact the notice appears but only if you refresh the page using F5.

Which cart event could I hook in order to set the shipping method before magento reads it?

Thanks

1

There are 1 answers

4
Amit Bera On BEST ANSWER

There no events is exits name of add_to_cart_before.

You can use other event like:

  • checkout_cart_save_before
  • checkout_cart_add_product_complete etc