3

I created an observer to add rule before customer can access one page checkout, the code for checking my rule before proceed to one page checkout page is working fine, but the problem is i want to add the error message if i redirect to checkout/cart but it only redirect to checkout cart not showing the error message, here's my code:

class Namespace_Module_Model_Observer
{
    public function checkAction(Varien_Event_Observer $observer)
    {
        $exist = Mage::helper('module')->check();
        if ($exist['key'] == 1) {
            if ($exist['total'] > 0) {
                return true;
            }
        } elseif ($exist['key'] == 0) {
            if ($exist['total'] > 0) {
                Mage::getSingleton('core/session')->addError('You need to configure Logo Branding first to proceed');
                Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl().'checkout/cart');
            }
        }
        return true;
    }
}
1

Please try to add

session_write_close();

before

Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl().'checkout/cart');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.