Hello,
I sometimes get this notice in the OPC page (frontend): COM_VIRTUEMART_COUNTRY_STATE_NOTEXIST
Any idea? Thank you
Joomla 3.8.10 / VM 3.2.15 / OPC 2.0.365
what is the status of your "US Mode" in Taxes and Prices tab in OPC ?
vmInfo('COM_VIRTUEMART_COUNTRY_STATE_NOTEXIST');
// vmInfo('COM_VIRTUEMART_COUNTRY_STATE_NOTEXIST');
/**
* Tests if a state and country fits together and if they are published
*
* @author Max Milbers
* @return String Attention, this function gives a 0=false back in case of success
*/
public static function testStateCountry(&$countryId, &$stateId, &$required) {
$countryId = (int)$countryId;
$stateId = (int)$stateId;
if(empty($countryId)) return true;
$db = JFactory::getDBO();
$q = 'SELECT * FROM `#__virtuemart_countries` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `published`="1"';
$db->setQuery($q);
if($db->loadResult()){
//Test if country has states
$q = 'SELECT * FROM `#__virtuemart_states` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `published`="1"';
$db->setQuery($q);
if($db->loadResult()){
if(!empty($stateId)){
//Test if virtuemart_state_id fits to virtuemart_country_id
$q = 'SELECT * FROM `#__virtuemart_states` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `virtuemart_state_id`="'.$stateId.'" and `published`="1"';
$db->setQuery($q);
if($db->loadResult()){
return true;
} else {
//There is a country, but the state does not exist or is unlisted
$stateId = 0;
vmLanguage::loadJLang('com_virtuemart_countries');
$x = debug_backtrace();
$msg = "\n";
$br = "<br />\n";
foreach ($x as $l) $msg .= @$l['file'].' '.@$l['line'].$br;
$msg .= 'country: '.var_export($countryId, true).$br;
$msg .= 'state: '.var_export($stateId, true).$br;
file_put_contents(JPATH_SITE.DIRECTORY_SEPARATOR.'statelog.html', $msg, FILE_APPEND);
//vmInfo('COM_VIRTUEMART_COUNTRY_STATE_NOTEXIST');
return false;
}
}
} else {
//This country has no states listed
$stateId = 0;
$required = false;
return true;
}
} else {
//The given country does not exist, this can happen, when non published country was chosen
$countryId = 0;
$stateId = 0;
vmLanguage::loadJLang('com_virtuemart_countries');
vmInfo('COM_VIRTUEMART_COUNTRY_NOTEXIST');
return false;
}
}