News:

Looking for documentation? Take a look on our wiki

Main Menu

Behaviour of agreed and TOS in checkout

Started by anthrobote, December 12, 2011, 21:57:49 PM

Previous topic - Next topic

anthrobote

I want to report two errors I encountered during the new order process regarding the agreement of Terms of Service:

Description:

  • 1. Provided that agreed user field is marked as required in administration, the "Terms of Service" checkbox selection during checkout and order confirmation is ignored, so the new order process continues to the next steps without a prompt to the user requiring him to agree to ToS at first. The negation (question mark) inside the "if condition" in .../helpers/cart.php causes this unwanted behavior (currently at line 829):
if(!$userFieldsModel->getIfRequired('agreed')){

$this->tosAccepted = JRequest::getInt('tosAccepted', $this->tosAccepted);

  • in that the JRequest::getInt(..) method occasionally fills $this->tosAccepted variable with string making it always pass the "not identity" test currently at line 824:
if ($this->tosAccepted !== 1) {

  • I have not investigated why string is being returned by Joomla API method, but it indeed happens.

VirtueMart Version:
1.9.8M

Joomla/Mambo Version:
1.7.3

Proposed fix(es):

  • 1. Temporary reverse the aforementioned condition – that makes the checkbox to be taken into account if agreed user field is marked as required in administration.
if($userFieldsModel->getIfRequired('agreed')){

  • But anyway, definitely this is not an optimal solution – an agreement with ToS should (or should not) be required based on the dedicated configuration option in administration, not this user-field-required trick. Also note that COM_VIRTUEMART_ADMIN_CFG_AGREE_TERMS_ONORDER serves a different purpose. This only sets the ToS checkbox as "checked" by default (so it works on an opt-out basis). But what we possibly want is an configuration option to disable ToS agreement requirement/check altogether (but obviously this can be illegal in some/many countries).

  • 2. Convert the returned value of the mentioned method into integer:
$this->tosAccepted = intval(JRequest::getInt('tosAccepted', $this->tosAccepted));

Bugtracker task #:
Not submitted yet.

When both the fixes are applied, it works as I believe it was expected to work.

Milbo

Interesting observation.

I wrote it so (or at least want it that way) that the agreed field works like a predefault, yes. So when "agree on TOS on every order" is unchecked, it works like directly agreeing to the TOS. On the other hand there is an extra field to read for the tos. You dont want to disturb the user while registration or entering data. But the TOS must be checked at the end of the checkout. So both systems work, people are just not forced directly to agree to the tos (there is also no link to the tos yet, so they would have to agree into the blue).
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

anthrobote

Yes it almost works as you say when the fixes I mentioned are applied. But another problem/bug I have just found is that the agreed field is not updated from the form (.../user/tmpl/edit_adress.php view) when switched from value 1 to value 0 (i.e. unchecked) - the problem resides in .../models/userfields.php which doesn't generate corresponding <input type="hidden" value="0"> to send the zero value via POST (hidden input should be added both to predefined checkbox for agreed field and to unknown checkboxes).

And one more bug: When user logs in and wants to change the state of checkbox for agreed field (for example during checkout). The checkbox appears always as unchecked even if the agreed field is set to 1 in the database. In other words, the agreed state is loaded only from the current session not from the database. But I am not sure if it's not some local problem in my modified version as I fiddle with the sources.

There are so many errors that it was a bit hard for me to grasp the whole logic, also I am very new to VirtueMart and its source code, so maybe I am missing something or using it badly :-)

anthrobote

I am sorry, the bugs from my first posts are now fixed in the latest beta versions of VirtueMart, but the one from my previous post remains.

doug4r

My agreed field is locked.  Where do I find the lastest beta versions of VirtueMart 2.0 that fixes this?

Doug

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Milbo

You can also change the locked fields, just go in the detailed edit view.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

anthrobote

What about the bugs I have mentioned, can you provide some clarification? The simple one concerning the hidden input field in models/userfields.php is still not corrected.

Thanks much.