News:

Looking for documentation? Take a look on our wiki

Main Menu

Missing value for Phone, required field change

Started by Thomas Kuschel, June 06, 2012, 10:26:17 AM

Previous topic - Next topic

Thomas Kuschel

Hi,

Configuration: VM 2.0.6

Description: I have an old user database coming from VM1. Several users (# 780) are stored without phone1 field filled out (it's empty).
Now, it's a required field, and I want to leave this field as required.
If such an 'old' user logs in, and enter the virtuemart shop, then after check out - or during checkout ? - , a message comes up:
"Missing value for Phone", and "You have to register for ...".
And _no_ invoice is generated.

Query: Why can't this user (without a required field) just make an order??? IMHO there's no need checking required fields within existing users!

I will digging into the code by myself,... I will describe it later on.
And I know, I could manipulate the database itself...; but I think this is a bug. - When somebody change a field requirement after some time...; even though it should work, if the value is missing.

regards,
Thomas

Thomas Kuschel

I've found the code, generating this behavior.
FILE: components/com_virtuemart/helpers/cart.php
There is a validation of the "neededFields", except virtuemart_state_id whithin function validateUserData($type='BT', $obj = null)
Line 941

foreach ($neededFields as $field) {

if($field->required && empty($this->{$type}[$field->name]) && $field->name != 'virtuemart_state_id'){
$redirectMsg = JText::sprintf('COM_VIRTUEMART_MISSING_VALUE_FOR_FIELD',JText::_($field->title) );
$i++;
//more than four fields missing, this is not a normal error (should be catche by js anyway, so show the address again.
if($i>2 && $type=='BT'){
$redirectMsg = JText::_('COM_VIRTUEMART_CHECKOUT_PLEASE_ENTER_ADDRESS');
}
}


This function validateUserData is called within the function checkoutData(redirect = true) ... (Note: But we check the data again to be sure)

I'm unsure where to change the code, I think a message could tell the missing field, but it must not redirect but going on.

Thomas