Programmatically set free shipping from an observer
So here is how I did it.
First, I have used more appropriate event for that purpose, that is sales_quote_collect_totals_before
. And second, I needed to comment out (in local copy of course), one line in Mage_SalesRule_Model_Quote_Freeshipping:
public function collect(Mage_Sales_Model_Quote_Address $address)
{
parent::collect($address);
$quote = $address->getQuote();
$store = Mage::app()->getStore($quote->getStoreId());
//$address->setFreeShipping(0); # clime: we set this in module
...
}
That is it. The following now works well:
$address = $quote->getShippingAddress();
$address->setFreeShipping(true); # the value must be true, not 1
It works well in single shipping mode. Multishipping is probably going to need some adjustments.