Author Topic: Shopper fields 'required' not showing in forms (password, username etc)  (Read 4630 times)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10302
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
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

Code: [Select]
//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

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

    [description] =>
)

if changed to

Code: [Select]
//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

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

    [description] =>
)

Cheers

GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 765
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest
Re: Shopper fields 'required' not showing in forms (password, username etc)
« Reply #1 on: October 20, 2013, 21:25:45 pm »
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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10302
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Shopper fields 'required' not showing in forms (password, username etc)
« Reply #2 on: October 20, 2013, 22:56:08 pm »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10144
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Shopper fields 'required' not showing in forms (password, username etc)
« Reply #3 on: October 23, 2013, 21:07:12 pm »
Suggestions?
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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10302
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Shopper fields 'required' not showing in forms (password, username etc)
« Reply #4 on: October 23, 2013, 21:09:20 pm »
working on it...  :)

Gruß
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10302
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Shopper fields 'required' not showing in forms (password, username etc)
« Reply #5 on: October 25, 2013, 18:08:16 pm »
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

Code: [Select]
//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

Code: [Select]
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

creyl

  • Beginner
  • *
  • Posts: 4
Thanks!! Really helped me!!