Few month ago, I had to modify custom shipping description, and make it dynamic.

A first solution was to override the getShippingDescription method in my module. But it’s a little creepy because it used an override.

Finally, I found a method thanks to an Observer :

<?xml version="1.0"?>
<config>
	<!-- ... -->
	<global>
		<!-- ... -->
        <events>
			<!-- ... -->
			<sales_quote_address_collect_totals_after>
                <observers>
                    <change_shipping_description>
                        <class>MyPackage_MyModule_Observer</class>
                        <method>changeShippingDescription</method>
                    </change_shipping_description>
                </observers>
			</sales_quote_address_collect_totals_after>
			<!-- ... -->
        </events>
		<!-- ... -->
	</global>
	<!-- ... -->
</config>

And the method on the Observer:

<?php

class MyPackage_MyModule_Model_Observer
{   
    public function changeShippingDescription($observer)
    {
		$events=$observer->getEvent();
        $address=$events->getQuoteAddress();
		$customMethod = "YOUR_METHOD"; // Put your custom shipping method here
        if($address->getAddressType()=='shipping' && $address->getShippingMethod() == $customMethod){
			$newShippingDescription = "My new shipping description";
			/* You can put your logic here and make the description dynamic */
			$address->setShippingDescription($newShippingDescription);
			$address->save();
		}
    }

}

Result in the admin :

shipping

 

If you need to have a fixed description, you don’t need this method ! Use the simple admin field of your custom module.

If you don’t know how to do this, get on this super article on Inchoo !
 

Change shipping description (Shipping & Handling Information)
Share on FacebookTweet about this on TwitterShare on Google+Email this to someone
Tagged on:         

One thought on “Change shipping description (Shipping & Handling Information)

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.
Ok