I have tried every different combo of model that returns a quote in order to try and find the one that has the quote for the current customer's cart.
So far none of them work, and I can't figure out why this might be.
Essentially I'm running an external script in the misc directory that sets a generated coupon code on the current cart, but none of the following set the code correctly and I have to default to redirecting to /checkout/cart/coupon/post or whatever the correct url is for that.
Here are the different models I have tried for getting the session:
$session = Mage::getSingleton("customer/session"); $session = Mage::getSingleton('checkout/session'); $session = Mage::getSingleton('core/session'); $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
And these are the different method's I've tried to run on the quote:
$quote->getShippingAddress()->setCollectShippingRates(true); $quote->setCartCouponCode($coupon); $quote->setCouponCode($coupon); $quote->collectTotals(); $quote->save();
They don't fail but they also do not set the code correctly.