girolimoni Posted September 21, 2009 Posted September 21, 2009 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; }
♥ecartz Posted September 21, 2009 Posted September 21, 2009 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.
girolimoni Posted September 21, 2009 Author Posted September 21, 2009 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
girolimoni Posted September 21, 2009 Author Posted September 21, 2009 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 . '"');
girolimoni Posted September 21, 2009 Author Posted September 21, 2009 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; }
burt Posted September 21, 2009 Posted September 21, 2009 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.
girolimoni Posted September 22, 2009 Author Posted September 22, 2009 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; }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.