title: Magento: setCouponCode does not seem to apply coupon on quote model
body: <p>we are using Magento mainly for transactions and have rewritten the frontend entirely through a custom application. I am having trouble applying a coupon code (shopping cart price rule) on a quote object. The coupon code seems to be rejected - setCouponCode does not return any error, but getCouponCode returns empty string. </p>
  
  <p>I have verified that the coupon code is valid by making a transacting through the admin backend. Here is the code snippet below. </p>
  
  <p>Can someone help me with getting the quote model object to accept and apply a coupon code?</p>
  
  <p>function add_coupon($shoppingCartId, $couponcode) {</p>
  
  <pre><code>    try {
              $quoteObj = Mage::getModel('sales/quote')-&gt;load($shoppingCartId);
              $quoteObj-&gt;getShippingAddress()-&gt;setCollectShippingRates(true);
              $quoteObj-&gt;getShippingAddress()-&gt;setCouponCode($coupon)
                      -&gt;setTotalsCollectedFlag(true)
                      -&gt;collectTotals()
                      -&gt;save();
      } catch (Exception $e) {
              return array("status"=&gt;"failed", "message"=&gt;"Error applying coupon.");
      }
      if ($coupon) {
              if (!$coupon == $quoteObj-&gt;getCouponCode()) {
                      return array("status"=&gt;"failed", "message"=&gt;"Coupon code is not valid.");
              }
      }
      return array("status"=&gt;"success");
  </code></pre>
  
  <p>}</p>