Author Topic: Behaviour of agreed and TOS in checkout  (Read 2363 times)

anthrobote

  • Beginner
  • *
  • Posts: 8
Behaviour of agreed and TOS in checkout
« on: December 12, 2011, 21:57:49 pm »
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):
Code: [Select]
if(!$userFieldsModel->getIfRequired('agreed')){
Code: [Select]
$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:
Code: [Select]
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.
Code: [Select]
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:
Code: [Select]
$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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bad condition causing Terms of Service checkbox to be ignored
« Reply #1 on: December 13, 2011, 02:15:10 am »
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).
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

anthrobote

  • Beginner
  • *
  • Posts: 8
Re: Bug causes the Terms of Service checkbox to be ignored
« Reply #2 on: December 13, 2011, 22:46:51 pm »
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

  • Beginner
  • *
  • Posts: 8
Re: Bug causes the Terms of Service checkbox to be ignored
« Reply #3 on: December 13, 2011, 23:00:36 pm »
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

  • Beginner
  • *
  • Posts: 18
Re: Behaviour of agreed and TOS in checkout
« Reply #4 on: January 17, 2012, 22:30:09 pm »
My agreed field is locked.  Where do I find the lastest beta versions of VirtueMart 2.0 that fixes this?

Doug

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27595
  • Always on vacation
    • Jenkin Hill Internet
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM 3.6.10.10211 on Joomla 3.9.13 PHP 7.0.33

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Behaviour of agreed and TOS in checkout
« Reply #6 on: January 18, 2012, 00:30:49 am »
You can also change the locked fields, just go in the detailed edit view.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

anthrobote

  • Beginner
  • *
  • Posts: 8
Re: Behaviour of agreed and TOS in checkout
« Reply #7 on: January 20, 2012, 13:20:52 pm »
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.