Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Age verification for a certain payment method


girolimoni

Recommended Posts

Posted

Hello,

 

Does anyone know how to adjust the following code in order to have the payment option available if age is above 18?

 

Thanks in advance.

 

 

// ageverification check

if ($order->billing['country_id'] != "100") {

$this->enabled = false;

}

Posted

Something like

global $customer_id;

$dob_query = tep_db_query("select customers_dob from " . TABLE_CUSTOMERS . " where customers_id='" . (int)$customer_id . '"');
$dob = tep_db_fetch_array($dob_query);

if ( strtotime($dob['customers_dob']) > strtotime('-18 years') ) {
 $this->enabled = false;
}

Always back up before making changes.

Posted
Something like
global $customer_id;

$dob_query = tep_db_query("select customers_dob from " . TABLE_CUSTOMERS . " where customers_id='" . (int)$customer_id . '"');
$dob = tep_db_fetch_array($dob_query);

if ( strtotime($dob['customers_dob']) > strtotime('-18 years') ) {
 $this->enabled = false;
}

 

 

Hi, cool thanks for your hint. will give a try as soon as possible !!!

 

greetings

Posted

Combined your post with a contribution and got this. but i have a syntax error:

 

global $customer_id;

 

$dob_query = tep_db_query("select customers_dob from " . TABLE_CUSTOMERS . " where customers_id='" . (int)$customer_id . '"');

$dob = tep_db_fetch_array($dob_query);

 

$day = substr(tep_date_raw($dob), 6, 2);

$month = substr(tep_date_raw($dob), 4, 2);

$year = substr(tep_date_raw($dob), 0, 4);

$today = getdate();

$cmonth = $today['mon'];

$cday = $today['mday'];

$cyear = $today['year'];

$fullyears = $cyear - $year;

//FIXED LINE IN 2.2

if ($cmonth < $month || ($cmonth == $month && $cday < $day)) $fullyears--;

//END OF 2.2 MOD

if ($fullyears < 18) {

$this->enabled = false;

}

 

 

error: select customers_dob from customers where customers_id='108"

 

so i think there is something wrong in: where customers_id='" . (int)$customer_id . '"');

Posted

o.k got it now but under 18 aged customers have the payment method still displayed :(. Any help please?

 

global $customer_id;

 

$dob_query = tep_db_query("select customers_dob from " . TABLE_CUSTOMERS . " where customers_id='" . (int)$customer_id . "'");

$dob = tep_db_fetch_array($dob_query);

 

$day = substr(tep_date_raw($dob), 6, 2);

$month = substr(tep_date_raw($dob), 4, 2);

$year = substr(tep_date_raw($dob), 0, 4);

$today = getdate();

$cmonth = $today['mon'];

$cday = $today['mday'];

$cyear = $today['year'];

$fullyears = $cyear - $year;

if ($fullyears < 18) {

$this->enabled = false;

}

Posted

Matts is better, but has an error in it (as far as I can make out);

 

	  $dob_query = tep_db_query("select customers_dob from " . TABLE_CUSTOMERS . " where customers_id='" . (int)$customer_id . "'");
  $dob = tep_db_fetch_array($dob_query);

  if ( strtotime($dob['customers_dob']) > strtotime('18 years ago') ) {
	$this->enabled = false;
  }

 

You still need to add the $customer_id to the global scope.

Posted

Hello Burt,

 

Thanks its working! Great support. Here for any other users who like to disable a payment method if the customer hasnt reached 18 (for example if you offer payment on account):

 

// deactivation of payment method if not 18

global $customer_id;

 

$dob_query = tep_db_query("select customers_dob from " . TABLE_CUSTOMERS . " where customers_id='" . (int)$customer_id . "'");

$dob = tep_db_fetch_array($dob_query);

 

if ( strtotime($dob['customers_dob']) > strtotime('18 years ago') ) {

$this->enabled = false;

}

Archived

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

×
×
  • Create New...