cancel
Showing results for 
Search instead for 
Did you mean: 

Programming Issue with Currency Switcher not switching when selecting

Programming Issue with Currency Switcher not switching when selecting

Hey everyone,

Ever since I added SSL to my website, the currency switcher has stopped working.

When I mouse over  USD/CAD/EUR  it shows the correct url LINK: 

Mysite.com/directory/curency/switch/currency/CAD  example;

However, when clicking on it, it does nothing, the site stays at the base URL  mysite.com

but, after clicking on it, and if you change category, or go to a different product page, it shows it correctly with the new currency only after changeing pages

So it seems to be not refreshing the page that its on.

I'm using Brim Full Page Cache, i don't know if this is a cache issue, or a rewrite issue with the URL.

I have options like shorten URL and all of that on.

5 REPLIES 5

Re: Programming Issue with Currency Switcher not switching when selecting

I'm not sure exactly whats causing this Smiley Sad

Re: Programming Issue with Currency Switcher not switching when selecting

This is the old code:

?>
<?php if($this->getCurrencyCount()>1): ?>
    <div class="block-currency">
        <select name="currency" title="<?php echo $this->__('Select Your Currency') ?>" onchange="setLocation(this.value)">
        <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
            <option value="<?php echo $this->getSwitchCurrencyUrl($_code) ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
                <?php echo $_name ?> - <?php echo $_code ?>
            </option>
        <?php endforeach; ?>
        </select>
    </div>
<?php endif; ?>


And this is the new current code:

<div class="block-currency">
     <ul id="currency">
       <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
               <li>
           <a href="<?php echo $this->getSwitchCurrencyUrl($_code) ?>" onclick="setLocation(this.value);">
                   <img src="<?php echo Mage::getBaseUrl('media').'flag/'.$_code.'.jpg'; ?>" title="<?php echo $_name ?> - <?php echo $_code ?>" alt="<?php echo $_name ?> - <?php echo $_code ?>" width="20" height="15"  />
       </a>
               </li>
            
       <?php endforeach; ?>
       </ul>     
    </div>

 

Re: Programming Issue with Currency Switcher not switching when selecting

This is the CurrencyController.php

{
    public function switchAction()
    {
        if ($curency = (string) $this->getRequest()->getParam('currency')) {
            Mage::app()->getStore()->setCurrentCurrencyCode($curency);
        }
        $this->_redirectReferer(Mage::getBaseUrl());
    }
}

 
and this is Action.php in the varien folder:

    protected function _getRefererUrl()
{
    $refererUrl = $this->getRequest()->getServer('HTTP_REFERER');
    if ($url = $this->getRequest()->getParam(self::PARAM_NAME_REFERER_URL)) {
        $refererUrl = $url;
    }
    if ($url = $this->getRequest()->getParam(self::PARAM_NAME_BASE64_URL)) {
        $refererUrl = Mage::helper('core')->urlDecode($url);
    }
    if ($url = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED)) {
        $refererUrl = Mage::helper('core')->urlDecode($url);
    }
 
    if (!$this->_isUrlInternal($refererUrl)) {
        $refererUrl = Mage::app()->getStore()->getBaseUrl();
    }
    
    $_isHttps = $this->getRequest()->getServer('HTTPS');
    if ($_isHttps && $_isHttps != 'off') {
        $refererUrl = str_replace('http', 'https', $refererUrl);
    }
 
    return $refererUrl;
}

 
Not sure if these 2 need to be more HTTPS specific as the entire site is HTTPS. 

Re: Programming Issue with Currency Switcher not switching when selecting

Did you code it yourself or utilized an extension, by the way, the following plugin works without any conflict with the ssl, 

 

http://www.magentocommerce.com/magento-connect/geo-ip-language-currency-switcher.html

Re: Programming Issue with Currency Switcher not switching when selecting

We have 2 extensions with Currency Switcher - our GeoIP Store and Currency Switcher that automatically switches language, store, currency, tax based on visitor's location, and blocks separate countries and IPs.

And our separate GeoIP Currency Switcher