is a long time that I try to solve a problem of my WebSite: When I make an order, and I do not accept the terms of service, the order goes on when it should be stopped. It should show instead a warning that feels the need of the terms of service with a popup ... can you solve this problem?
i already enabled in the settings that need to accept the terms of service to every order
:'(
i use 2.0.24b
I have the same problem on Joomla! 2.5.17 and 2.0.26a
If I use VM 2.0.24, everything works fine.
After directly upgrading to 2.0.26a without additional changes, "accepting the TOS" is NOT validated any more correctly.
This problem starts directly after upgrading.
I found the error, it is in "components/com_virtuemart/helpers/cart.php"
In Version 2.0.24 looks like
if(!empty($agreed->required) and empty($agreed->default) and !empty($this->BT)){
In Version 2.0.26a on line 865, it looks like
if(!empty($agreed->required) and $agreed->default!=='' and $validUserDataBT!==-1){
Fix this to:
if(!empty($agreed->required) and $agreed->default=='' and $validUserDataBT!==-1){
The error is in the negotiation of
$agreed->default==''
Could the VM developers please confirm this as a bug and fix it?
damn c version, eh?
Please try this
if (empty($this->tosAccepted)) {
$userFieldsModel = VmModel::getModel('Userfields');
$agreed = $userFieldsModel->getUserfield('agreed','name');
if($agreed->default){
$this->tosAccepted = $agreed->default;
}
if(empty($this->tosAccepted) and !empty($agreed->required) and $validUserDataBT!==-1){
$redirectMsg = null;// JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');
$this->tosAccepted = false;
vmInfo('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS','COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');
return $this->redirecter('index.php?option=com_virtuemart&view=cart' , $redirectMsg);
}
}
OK, Thanks Milbo.
This code is better to understand, and it works for me ;-)
ahh now I found the quirk in all of this, please try this code
if(!isset($this->tosAccepted)){
$userFieldsModel = VmModel::getModel('Userfields');
$agreed = $userFieldsModel->getUserfield('agreed','name');
$this->tosAccepted = $agreed->default;
}
if (empty($this->tosAccepted)) {
$userFieldsModel = VmModel::getModel('Userfields');
$agreed = $userFieldsModel->getUserfield('agreed','name');
if(empty($this->tosAccepted) and !empty($agreed->required) and $validUserDataBT!==-1){
$redirectMsg = null;// JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');
$this->tosAccepted = false;
vmInfo('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS','COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');
return $this->redirecter('index.php?option=com_virtuemart&view=cart' , $redirectMsg);
}
}
Hey milbo,
thank you. This code also works.
There is only one thing, I'd like to know. This problem seems to happen only in some special cases, which I couldn't figure out so far.
I have another 2.0.26a installation, without this problem.
Could you explain, in which case this error happens?