Shopper fields 'required' not showing in forms (password, username etc)

Started by GJC Web Design, October 20, 2013, 21:02:29 PM

Previous topic - Next topic

GJC Web Design

Hi - have noticed with

2.0.24 that in the BT address form the required is missing for all the core fields except email (password, username etc)

tracked it down to  administrator/components/com_virtuemart/models/userfields.php ~ line 506

//Small ugly hack to make registering optional //do we still need that? YES !  notice by Max Milbers
if($register && $type == 'BT'  && VmConfig::get('oncheckout_show_register',1) ){

$corefields = $this->getCoreFields();
unset($corefields[2]); //the 2 is for the email field, it is necessary in almost anycase.
foreach($userFields as $field){
if(in_array($field->name,$corefields)){
$field->required = 0;
$field->value = '';
$field->default = '';

}
}


as I read this it sets all core field required to 0 therefore at the frontend e.g

Array
(
    [name] => password2
    [value] =>
    [title] => Confirm Password
    [type] => password
    [required] => 0
    [hidden] =>
    [formcode] =>

    [description] =>
)


if changed to

//Small ugly hack to make registering optional //do we still need that? YES !  notice by Max Milbers
if($register && $type == 'BT'  && VmConfig::get('oncheckout_show_register',1) ){

$corefields = $this->getCoreFields();
unset($corefields[2]); //the 2 is for the email field, it is necessary in almost anycase.
foreach($userFields as $field){
if(in_array($field->name,$corefields)){
$field->required = 1;
$field->value = '';
$field->default = '';

}
}


everything works as expected

Array
(
    [name] => password2
    [value] =>
    [title] => Confirm Password
    [type] => password
    [required] => 1
    [hidden] =>
    [formcode] =>

    [description] =>
)


Cheers

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jumbo!

Those fields are not required in VirtueMart account page because even guest users need to save their Bill To address who does not need to register. If you set these fields as required then guest checkout will not work in your site.

GJC Web Design

Ok - so not a bug - just an awful way of doing it..

then my answer is the same as in post   http://forum.virtuemart.net/index.php?topic=119722.0      :)

But there are loads of posts asking why the validation and validation styling is so - well - quirky..

Cheers
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

GJC Web Design

This seems to work fine - gives correct validation on must register and no problems on the other two cases

administrator/components/com_virtuemart/models/userfields.php ~ line 506


//Small ugly hack to make registering optional //do we still need that? YES !  notice by Max Milbers
if($register && $type == 'BT'  && VmConfig::get('oncheckout_show_register',1) ){
$corefields = $this->getCoreFields();
unset($corefields[2]); //the 2 is for the email field, it is necessary in almost anycase.
if (!VmConfig::get ('oncheckout_only_registered', 0)) {
foreach($userFields as $field){
if(in_array($field->name,$corefields)){
$field->required = 0;
$field->value = '';
$field->default = '';
}
}
}
}


administrator/components/com_virtuemart/models/userfields.php ~ line 861


case 'password':
case 'password2':
$_return['fields'][$_fld->name]['formcode'] = '<input type="password" id="' . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name .'" '.($_fld->required ? ' class="required"' : ''). ' size="30" class="inputbox" />'."\n";
break;




[attachment cleanup by admin]
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation