Magento Forum

   
Restrict checkout based on age
 
Ian Kullhem
Jr. Member
 
Total Posts:  12
Joined:  2008-09-09
 

Hello everyone,

I’m working on a store where the client needs to restrict the checkout process to customers over a certain age. I’ve found a place to require the birthdate on registration and disabled guest checkout, but I’m not sure where to go with preventing the registration from being accepted if the birthdate is sooner than a certain date.

Any help and guidance on this would be greatly appreciated.

Thanks
--
Ian Kullhem

 
Magento Community Magento Community
Magento Community
Magento Community
 
pastanislas
Member
 
Total Posts:  46
Joined:  2008-07-29
 

hello,
I’ve figured out the same problem.
To solve it I’ve just created a new terms and conditions (Sales -> terms and conditions) called “I confirm I am at least 21 years of age.”
Hope this helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
laProbeta
Member
 
Total Posts:  35
Joined:  2008-10-21
 

It would be nice that Varien took a necessary control like this in action. Many countries laws require this!

A fast approach to discourage users under 14 to register consists on modifiying js/varien/js.js to add the code below. It’s not nice since,

(1) It modifies magento-core/Lib-Js-Mage! Do it at your own risk
(2) It just acts at the presentation level
(3) Age is hardcoded, not configurable

Varien.DOB = Class.create();
Varien.DOB.prototype {
    [
...]
    validate
: function() {
        
var error false;
        
[...]
        
if (this.day.value=='' && this.month.value=='' && this.year.value==''{
            [
...]
            
var dateLegal = new Date(date.getFullYear() - 14date.getMonth(), date.getDate() );
            if (
test.valueOf() > dateLegal.valueOf()) {
                error 
'We are afraid that legal requirements demand us you to be at least 14 years old.';
            
}
        }
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
R.
Jr. Member
 
Total Posts:  17
Joined:  2009-09-07
 

Hi,

you can check age on PreDispatch() method in OnepageController.php

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top