Quantity Buttons Update Currency Issue

If you are runnig Joomla 3.x and Virtuemart 3.x please post to this forum your questions or support tickets about One Page Checkout

Quantity Buttons Update Currency Issue

Postby atrus80 » Wed Jul 01, 2015 7:17 pm

Hi Stan

See below link from product details page:

http://www.quality-tuning.eu/engine-bay ... ry_id=1615

When you update the qty button, the currency changes (from euro to gbp). We have assigned the euro currency to this language/domain and it works ok everywhere in the site but for the update qty setting it switches to gbp (gbp is the currency for the default site language, which is en-GB)

I asked the template developer and he told me that there should be no problem with the template because he has not modifies any vm core javascript functionality.

Would appreciate your feedback on this!

Rgrds,
Chris
atrus80
 
Posts: 85
Joined: Mon Feb 06, 2012 6:22 pm

Re: Quantity Buttons Update Currency Issue

Postby admin » Thu Jul 02, 2015 2:38 pm

hello chris, we had located the problem to the VM's vmLang javascript variable which in your case incorrectly sends lang=en instead of lang=eu to decide which langauge should be set within the Ajax content.

for now we had suggested a VM fix for vm3.0.10 that can be downloaded from here:

http://www.rupostel.com/svn3/patch.1435839641.svn.txt
http://www.rupostel.com/svn3/vmjsapi.php

for anybody having problems with VM3 on multi lang sites, we would suggest this code change:

locate file:
\administrator\components\com_virtuemart\helpers\vmjsapi.php

look for this code:
Code: Select all


if(VmConfig::get( 'vmlang_js', 1 )) {
         $jsVars .= "vmLang = '&lang=".substr( VmConfig::$vmLangSelected, 0, 2 )."' ;\n";
      } else {
         $jsVars .= 'vmLang = "";'."\n";
      }


and change to:

Code: Select all
$langs = VmConfig::get('active_languages', array());
if (count($langs)>1)
      {
         $code = self::getLangCode();
         
         if (!empty($code))
         $jsVars .= "vmLang = '&lang=".$code."'; \n";
          else
         $jsVars .= "vmLang = ''; \n";
      } else {
         $jsVars .= 'vmLang = ""; '."\n";
      }



and the most importantly ADD THIS FUCNTION to the class (before the last ending bracket at the end of the file):

Code: Select all

   /*stAn function - detect proper SEF language variable on j2.5/j3.x/j1.5  */
public static function getLangCode()
{
       $langO = JFactory::getLanguage();
      $lang = JRequest::getVar('lang', '');
      $locales = $langO->getLocale();
      $tag = $langO->getTag();
      $app = JFactory::getApplication();       
      
      /* this code is uses logic derived from language filter plugin in j3 and should work on most 2.5 versions as well */
      if (class_exists('JLanguageHelper') && (method_exists('JLanguageHelper', 'getLanguages')))
      {
      $sefs       = JLanguageHelper::getLanguages('sef');
      foreach ($sefs as $k=>$v)
      {
         if ($v->lang_code == $tag)
         if (isset($v->sef))
         {
            $ret = $v->sef;

            return $ret;
         }
      }
      }
      
      
      
         if ( version_compare( JVERSION, '3.0', '<' ) == 1) {       
         if (isset($locales[6]) && (strlen($locales[6])==2))
         {
            /* this is joomla 2.5 sef language var */
            
            $action_url .= '&amp;lang='.$locales[6];
            $lang = $locales[6];
            return $lang;
         }
         else
         if ( version_compare( JVERSION, '1.6', '<' ) == 1)
         if (!empty($locales[4]))
         {
            /* this is legacy joomla 1.5 code to detect sef language var*/
            
            $lang = $locales[4];
            
            if (stripos($lang, '_')!==false)
            {
               $la = explode('_', $lang);
               $lang = $la[1];
               if (stripos($lang, '.')!==false)
               {
                  $la2 = explode('.', $lang);
                  $lang = strtolower($la2[0]);
               }
            
               
            }
              return $lang;
         }
         else
         {
            return $lang;
         
         }
          }
         // return what we got at first
         return $lang;
}


if you want to keep compatiblity with upcoming Joomla 3.5, you may need to change JRequest to vRequest.
The code comes from our OPC and is tested on 1000 sites.

Best Regards, Stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 3 on Joomla 3.x