Skip to main content
deleted 214 characters in body
Source Link
Rick Buczynski
  • 2.7k
  • 15
  • 22

You can try to create an observer in a module, preferrable your own module in the local code pool:

<!-- app/code/local/Mymodule/etc/config.xml -->
...
<global>
    <events>
        ...
        <sales_model_service_quote_submit_after><sales_order_place_after>
            <observers>
                <clear_session>
                    <class>Mymodule_Model_Observer</class>
                    <method>clearCheckoutSession</method>
                </clear_session>
            </observers>
        </sales_model_service_quote_submit_after>sales_order_place_after>
    </events>
</global>
...

Don't know how this works? See here:

http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method

Once you declare the observer, build it out:

<?php

// app/code/local/Mymodule/Model/Observer.php

class Mymodule_Model_Observer 
    extends Varien_Event_Observer
{

    public function clearCheckoutSession()
    {
        Mage::getSingleton('core/session')->clear(); // Or whatever you want to clear
    }

}

You'll want to customize this to your needs, obviously. And put some verification checks in there as well.

Something to note is thatEDIT: As per laketuna's suggestion, I changed the target event we observe in the config XML,to sales_model_service_quote_submit_aftersales_order_place_after, is dispatched out of Mage_Sales_Model_Service_Quote::submitOrder -as it is triggered afterseems to be the order has completed. But, there are other events in there which might fit your need (eg: checkout_type_onepage_save_order)most reliable one to observe.

You can try to create an observer in a module, preferrable your own module in the local code pool:

<!-- app/code/local/Mymodule/etc/config.xml -->
...
<global>
    <events>
        ...
        <sales_model_service_quote_submit_after>
            <observers>
                <clear_session>
                    <class>Mymodule_Model_Observer</class>
                    <method>clearCheckoutSession</method>
                </clear_session>
            </observers>
        </sales_model_service_quote_submit_after>
    </events>
</global>
...

Don't know how this works? See here:

http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method

Once you declare the observer, build it out:

<?php

// app/code/local/Mymodule/Model/Observer.php

class Mymodule_Model_Observer 
    extends Varien_Event_Observer
{

    public function clearCheckoutSession()
    {
        Mage::getSingleton('core/session')->clear(); // Or whatever you want to clear
    }

}

You'll want to customize this to your needs, obviously. And put some verification checks in there as well.

Something to note is that the event we observe in the config XML, sales_model_service_quote_submit_after, is dispatched out of Mage_Sales_Model_Service_Quote::submitOrder - it is triggered after the order has completed. But, there are other events in there which might fit your need (eg: checkout_type_onepage_save_order).

You can try to create an observer in a module, preferrable your own module in the local code pool:

<!-- app/code/local/Mymodule/etc/config.xml -->
...
<global>
    <events>
        ...
        <sales_order_place_after>
            <observers>
                <clear_session>
                    <class>Mymodule_Model_Observer</class>
                    <method>clearCheckoutSession</method>
                </clear_session>
            </observers>
        </sales_order_place_after>
    </events>
</global>
...

Don't know how this works? See here:

http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method

Once you declare the observer, build it out:

<?php

// app/code/local/Mymodule/Model/Observer.php

class Mymodule_Model_Observer 
    extends Varien_Event_Observer
{

    public function clearCheckoutSession()
    {
        Mage::getSingleton('core/session')->clear(); // Or whatever you want to clear
    }

}

You'll want to customize this to your needs, obviously. And put some verification checks in there as well.

EDIT: As per laketuna's suggestion, I changed the target event to sales_order_place_after, as it seems to be the most reliable one to observe.

Source Link
Rick Buczynski
  • 2.7k
  • 15
  • 22

You can try to create an observer in a module, preferrable your own module in the local code pool:

<!-- app/code/local/Mymodule/etc/config.xml -->
...
<global>
    <events>
        ...
        <sales_model_service_quote_submit_after>
            <observers>
                <clear_session>
                    <class>Mymodule_Model_Observer</class>
                    <method>clearCheckoutSession</method>
                </clear_session>
            </observers>
        </sales_model_service_quote_submit_after>
    </events>
</global>
...

Don't know how this works? See here:

http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method

Once you declare the observer, build it out:

<?php

// app/code/local/Mymodule/Model/Observer.php

class Mymodule_Model_Observer 
    extends Varien_Event_Observer
{

    public function clearCheckoutSession()
    {
        Mage::getSingleton('core/session')->clear(); // Or whatever you want to clear
    }

}

You'll want to customize this to your needs, obviously. And put some verification checks in there as well.

Something to note is that the event we observe in the config XML, sales_model_service_quote_submit_after, is dispatched out of Mage_Sales_Model_Service_Quote::submitOrder - it is triggered after the order has completed. But, there are other events in there which might fit your need (eg: checkout_type_onepage_save_order).