title: Magento: programmatically set free shipping
body: <p>I am programming a module where I need to set free shipping of a quote on a certain occasions. I am trying to get this working:</p>
  
  <pre><code>$quote = Mage::helper('checkout/cart')-&gt;getCart()-&gt;getQuote();
  $quote-&gt;getShippingAddress()-&gt;setFreeShipping(1);
  </code></pre>
  
  <p>but so far no success. Can anyone help?</p>
  
  <p>EDIT: I need to do this from on the following events:</p>
  
  <pre><code>checkout_cart_update_items_after
  checkout_cart_product_add_after
  sales_quote_remove_item
  </code></pre>
  
  <p>Basically upon any cart modification I need to determine if shipping should be free of charge.</p>
  
  <p>EDIT: This seems to work pretty well. Except I would need to disable free shipping as a choice in checkout.</p>
  
  <pre><code>$address = $quote-&gt;getShippingAddress();
  $address-&gt;setShippingMethod('freeshipping_freeshipping');
  </code></pre>