Undefined property: TableUserinfos::$virtuemart_state_id

Started by ViPeS, January 05, 2023, 20:37:43 PM

Previous topic - Next topic

ViPeS

Hi!
J 4.2.6,  VM 4.0.12 10777, PHP 8.0
Error when opening product for editing
Undefined property: TableUserinfos::$virtuemart_state_id in /home/viinis/domains/virtuvinis.lt/public_html/administrator/components/com_virtuemart/helpers/calculationh.php on line 262

What is $virtuemart_state_id ?
VM 4.2.18 11050, Joomla 5.2.1, PHP 8.3.8

Milbo

Thank you for this bug report. I think the solution is quite easy, analogue to the vendorAdress some lines below

if (isset( $userFieldsBT->virtuemart_country_id)){
$this->_deliveryCountry = $userFieldsBT->virtuemart_country_id;
}
if (isset( $userFieldsBT->virtuemart_state_id)) {
$this->_deliveryState = $userFieldsBT->virtuemart_state_id;
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

ViPeS

Hi, thanks for the reply!
I did as you suggested, but the error didn't go away.
I just commented out the line and the error didn't show up anymore.
//$this->_deliveryState = $userFieldsBT->virtuemart_state_id;
if (!VmConfig::isSite()) {

$userModel = VmModel::getModel('user');
$userDetails = $userModel->getUser();
if(!empty($userDetails->userInfo)){
$userFieldsBT = reset($userDetails->userInfo);
$this->_deliveryCountry = $userFieldsBT->virtuemart_country_id;
//$this->_deliveryState = $userFieldsBT->virtuemart_state_id;
//vmdebug('My UserDetails',$this->_deliveryCountry,$this->_deliveryState,$userFieldsBT);
} else {
$vendorModel = VmModel::getModel ('vendor');
$vendorAddress = $vendorModel->getVendorAdressBT (1);
if (isset( $userFieldsBT->virtuemart_country_id)){
$this->_deliveryCountry = $userFieldsBT->virtuemart_country_id;
}
if (isset( $userFieldsBT->virtuemart_state_id)) {
$this->_deliveryState = $userFieldsBT->virtuemart_state_id;
}
}
return;
}
VM 4.2.18 11050, Joomla 5.2.1, PHP 8.3.8