Search code examples
sessionmagentocountry

How to clear the shipping and country selection only from the session


I run Magento with multiple store views.

I would like to know how to clear/destroy the country and the shipping selection when a user changes the store view. I assume this is stored in the session.

I know how to retrieve the session data for the language selection:

$mageFilename = 'app/Mage.php';
require_once $mageFilename;

umask(0);
Mage::app();

$quote = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getCountry_id();

echo $quote;

But I don't know how to clear it or unset it before the page loads.


Solution

  • As per my thought and logic it should work for your

    As magento provide set and get method for different variable name so in quote also will work for you

    just try like below

    if the flag is set, making...

    Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(null);
    
    OR 
    
    Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress->setCountry_id(null);
    

    just try or find out in mage core to get your solution.