Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Age restricted category using date of birth


Guest

Recommended Posts

If you need to make an age restricted area in your store, see below.

 

In create_account.php (around lines 219-227), change

      $customer_first_name = $firstname;
     $customer_default_address_id = $address_id;
     $customer_country_id = $country;
     $customer_zone_id = $zone_id;
     tep_session_register('customer_id');
     tep_session_register('customer_first_name');
     tep_session_register('customer_default_address_id');
     tep_session_register('customer_country_id');
     tep_session_register('customer_zone_id');

to

      $customer_first_name = $firstname;
     $customer_default_address_id = $address_id;
     $customer_country_id = $country;
     $customer_zone_id = $zone_id;
     $customer_dob = tep_date_raw($dob);
     tep_session_register('customer_id');
     tep_session_register('customer_first_name');
     tep_session_register('customer_default_address_id');
     tep_session_register('customer_country_id');
     tep_session_register('customer_zone_id');
     tep_session_register('customer_dob');

In login.php (around line 28), change

    $check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");

to

    $check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_password, customers_email_address, customers_default_address_id, customers_dob from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");

Around lines 44-53, change

        $customer_id = $check_customer['customers_id'];
       $customer_default_address_id = $check_customer['customers_default_address_id'];
       $customer_first_name = $check_customer['customers_firstname'];
       $customer_country_id = $check_country['entry_country_id'];
       $customer_zone_id = $check_country['entry_zone_id'];
       tep_session_register('customer_id');
       tep_session_register('customer_default_address_id');
       tep_session_register('customer_first_name');
       tep_session_register('customer_country_id');
       tep_session_register('customer_zone_id');

to

        $customer_id = $check_customer['customers_id'];
       $customer_default_address_id = $check_customer['customers_default_address_id'];
       $customer_first_name = $check_customer['customers_firstname'];
       $customer_country_id = $check_country['entry_country_id'];
       $customer_zone_id = $check_country['entry_zone_id'];
       $customer_dob = $check_customer['customers_dob'];
       tep_session_register('customer_id');
       tep_session_register('customer_default_address_id');
       tep_session_register('customer_first_name');
       tep_session_register('customer_country_id');
       tep_session_register('customer_zone_id');
       tep_session_register('customer_dob');

Set Restricted as one of the top level categories. Find out what the categories_id is (hint: when you click on the link, it will be the first number after cPath= in the URL). In includes/application_top.php, after (around lines 491-8)

  if (tep_not_null($cPath)) {
   $cPath_array = tep_parse_category_path($cPath);
   $cPath = implode('_', $cPath_array);
   $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
 } else {
   $cPath_array = array();
   $current_category_id = 0;
 }

add

  if ($cPath_array[0] == '27') {
   if (!tep_session_is_registered('customer_dob')) {
     $navigation->set_snapshot();
     tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
   } else {
     $year    = (int)substr($customer_dob, 0, 4);
     $month = (int)substr($customer_dob, 4, 2);
     $day     = (int)substr($customer_dob, 6, 2);
     $date_now = get_date();
     if (!((($date_now['year'] - $year) > 18) || ((($date_now['year'] - $year) == 18) && ($date_now['mon'] > $month)  || ((($date_now['year'] - $year) == 18) && ($date_now['mon'] == $month) && ($date_now['mday'] > $day)))) {
       tep_redirect(tep_href_link(FILENAME_CONDITIONS));
     }
   }
 }

Replace 27 with the actual categories_id of your restricted category. Note: this is actually overly restrictive for places where the age is 18, mainly because I didn't know how to determine the time zone. Therefore, I pushed it a day late to make sure. You could drop the date of birth stuff and use a new field in the database to get much the same effect. This would simplify the code somewhat.

 

Hth,

Matt

Link to comment
Share on other sites

If you have a real cc processor that will auth and not capture a card, like paymentech where you have a batch function you can retain age verification if you force them to submit cc info to sign up. Did that for a couple of people and it worked beutifully, I know its a little off the subject, and you have to force a transaction on them even if they are not charged. but it is a great way to keep your viewers/customers legal. One client I put the cc payment module on the signup form and tweeked it to just run the cards algorythems, but that you just get they have a card not actual verification of there age.

Link to comment
Share on other sites

How do you verify the real age of the buyer if he/she intentionally give you a fake DOB?
Given a motivated enough liar, you don't.

 

The credit card trick is good (improves your legal standing), but it's not an absolute. What if they give you a parent's name, credit card, and date of birth? In some cases, it is enough to make them state their age. Check with a local lawyer on the laws and requirements that apply to you. As I said, you can drop the dob code and use a different database column instead if more verification is needed.

 

Hth,

Matt

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

matt,

 

this is excellent stuff....

 

Suppose tho i just want to set the category as restricted until you agree to terms? ie - send them to a warning page - must be over 18 click here to proceed or here to leave....

 

Any thots?

Link to comment
Share on other sites

At the top of the page add

if ($cPath_array[0] == '27') {
   if (!tep_session_is_registered('agreed_to_terms') || ($agreed_to_terms != 'yes')) {
     tep_redirect(tep_href_link(FILENAME_AGREE_TO_TERMS));
   }
 }

instead. You will also need to add a basic form page and put its name in the includes/filenames.php file. In the basic form page, if they agree to terms (click the checkbox or whatever), do a tep_session_register of agreed_to_terms and set it to 'yes'.

 

Note: this is slightly different than the way that they do it. They use something like the above code to check if the page should be restricted and if the terms have not been read. If both conditions hold, they show the page that you see on first click. Otherwise they show the normal product page.

 

Hth,

Matt

Always back up before making changes.

Link to comment
Share on other sites

  • 3 weeks later...

btw - i tried the orginal code verbatim - it doesnt work - parse errors out the wazoo.

 

Parse error: parse error in /home/httpd/vhosts/inncasinos.com/httpdocs/includes/application_top.php on line 497

 

Warning: main(DIR_WS_LANGUAGES/FILENAME_DEFAULT): failed to open stream: No such file or directory in /home/httpd/vhosts/inncasinos.com/httpdocs/index.php on line 24

 

Fatal error: main(): Failed opening required 'DIR_WS_LANGUAGES/FILENAME_DEFAULT' (include_path='.:/usr/share/pear') in /home/httpd/vhosts/inncasinos.com/httpdocs/index.php on line 24

 

Please note that the line # differences are do to mods and contributions installed - not my inability to read.

Link to comment
Share on other sites

  • 2 years later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...