VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: maxlatino74 on November 21, 2013, 23:56:06 PM

Title: Terms of service
Post by: maxlatino74 on November 21, 2013, 23:56:06 PM
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
Title: Re: Terms of service
Post by: shopper999 on January 07, 2014, 16:21:18 PM
I have the same problem on Joomla! 2.5.17 and 2.0.26a
Title: Re: Terms of service
Post by: shopper999 on January 08, 2014, 12:26:52 PM
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?


Title: Re: Terms of service
Post by: Milbo on January 08, 2014, 13:18:30 PM
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);
}
}
Title: Re: Terms of service
Post by: shopper999 on January 08, 2014, 13:58:21 PM
OK, Thanks Milbo.
This code is better to understand, and it works for me ;-)

Title: Re: Terms of service
Post by: Milbo on January 08, 2014, 17:21:53 PM
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);
}
}
Title: Re: Terms of service
Post by: shopper999 on January 09, 2014, 00:07:26 AM
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?