Hi,
I wish to get currency automatically selected as per geographic IP. For this I tried this code, which checks, if the user is from India, select virtuemart_currency_id= 356, else do default. I am facing problem with this. The currency label gets changed to INR but the prices are still listed in USD (default currency).
<?php // no direct access
defined('_JEXEC') or die('Restricted access');
vmJsApi::jQuery();
vmJsApi::chosenDropDowns();
?>
<?php
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
$result = "Unknown";
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
$ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if($ip_data && $ip_data->geoplugin_countryName != null)
{
$result = $ip_data->geoplugin_countryName;
}
if($result == 'India')
{
//Page for indian visitor
?>
<!-- Currency Selector Module -->
<?php echo $text_before
?>
<form id="selectform" class="cur_box" action="<?php echo vmURI::getCleanUrl() ?>" method="post">
<?php echo JHTML::_('select.genericlist', $currencies, 'virtuemart_currency_id', "class='inputbox' OnChange='submit();return false;'", 'virtuemart_currency_id', 'currency_txt', 356); ?>
</form>
<script type="text/javascript" src="<?php echo T3_TEMPLATE_URL ?>/html/mod_virtuemart_currencies/jquery.formstyler.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('#selectform select').styler();
});
</script>
<?php }
else
{
//Page for other visitor
?>
<!-- Currency Selector Module -->
<?php echo $text_before ?>
<form id="selectform" class="cur_box" action="<?php echo vmURI::getCleanUrl() ?>" method="post">
<?php echo JHTML::_('select.genericlist', $currencies, 'virtuemart_currency_id', "class='inputbox' OnChange='submit();return false;'", 'virtuemart_currency_id', 'currency_txt', $virtuemart_currency_id); ?>
</form>
<script type="text/javascript" src="<?php echo T3_TEMPLATE_URL ?>/html/mod_virtuemart_currencies/jquery.formstyler.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('#selectform select').styler();
});
</script>
<?php }
?>
Please help me as to get product currencies listed as per the currency code.
Thanks