• How can I limit the age of my customers to people over 18?

    There is no certain way to check on a visitor's age, but you can check that the date of birth that they have given you would make them at least 18 (or any other age you choose).

    To do this create an over-ride file in your template for includes/modules/create_account.php

    Find the section of code that reads
      if (ACCOUNT_DOB == 'true') {
        if (ENTRY_DOB_MIN_LENGTH > 0 or !empty($_POST['dob'])) {
          if (substr_count($dob,'/') > 2 || checkdate((int)substr(zen_date_raw($dob), 4, 2), (int)substr(zen_date_raw($dob), 6, 2), (int)substr(zen_date_raw($dob), 0, 4)) == false) {
            $error = true;
            $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
          }
        }
      }


    and expand it to (setting the minimum age to whatever you wish)

      if (ACCOUNT_DOB == 'true') {
        if (ENTRY_DOB_MIN_LENGTH > 0 or !empty($_POST['dob'])) {
          if (substr_count($dob,'/') > 2 || checkdate((int)substr(zen_date_raw($dob), 4, 2), (int)substr(zen_date_raw($dob), 6, 2), (int)substr(zen_date_raw($dob), 0, 4)) == false) {
            $error = true;
            $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
          }
          $minimum_age = 18;
          $acceptable_dob = (date('Y') - $minimum_age) . date('md');
          if (zen_date_raw($dob) > $acceptable_dob) {
            $error = true;
            $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_UNDERAGE);
          }               
        }
      }


    (note for the purists: yes, the minimum age should really be an Admin switch and yes, this is taking liberties with PHP's weak typing)

    Then create an over-ride file for your includes/languages/english/create_account.php file and place the following line in there, changing the text to suit your style of feeding errors back to visitors

    define('ENTRY_DATE_OF_BIRTH_UNDERAGE','Sorry, but you must be at least 18 to register to use this site');
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR