Page 1 of 2

Birth date - registration form

Posted: Wed Jun 23, 2010 3:04 pm
by RBS
Hi,

Is it somehow possible to add the birth date column into the registration form?

Thanks!

Regards,
RBS

Re: Birth date - registration form

Posted: Wed Jun 23, 2010 3:18 pm
by alex.lin
add 'birth_date' filed to table customer:

Code: Select all

ALTER TABLE  `customer` ADD  `birth_date` DATE NULL AFTER  `fax`
and add the code in the catalog\view\theme\default\template\account\create.tpl

Code: Select all

    <tr>
            <td><span class="required">*</span> <?php echo $entry_t birth_date; ?></td>
            <td><input type="text" name="birth_date" value="<?php echo $birth_date; ?>" />
              <?php if ($error_birth_date) { ?>
              <span class="error"><?php echo $error_birth_date; ?></span>
              <?php } ?></td>
          </tr>
then add code in the catalog\language\english\account\create.php

Code: Select all

$_['entry_birth_date']      = 'Birthday:'; 
add code in the catalog\controller\account\create.php

Code: Select all

$this->data['entry_birth_date'] = $this->language->get('entry_birth_date');

if (isset($this->error['birth_date'])) {
            $this->data['error_birth_date'] = $this->error['birth_date'];
        } else {
            $this->data['error_birth_date'] = '';
}    

if (isset($this->request->post['birth_date'])) {
            $this->data['birth_date'] = $this->request->post['birth_date'];
        } else {
            $this->data['birth_date'] = '';
    } 
and remeber change editCustomer() and editCustomer in catalog\model\account\customer.php

Re: Birth date - registration form

Posted: Wed Jun 23, 2010 8:46 pm
by fido-x
Here's another little tweak you can add to this one.

Copy the "ui" folder from the "admin/view/javascript/jquery" directory to the "catalog/view/javascript/jquery" directory. Edit your "catalog/view/theme/YOUR_THEME/template/common/header.tpl" by inserting the following lines in the <head> section (before the closing </head>:-

Code: Select all

<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/ui/themes/ui-lightness/ui.all.css" />
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/ui.core.js"></script>
Then, change the following:-
alex.lin wrote:and add the code in the catalog\view\theme\default\template\account\create.tpl

Code: Select all

    <tr>
            <td><span class="required">*</span> <?php echo $entry_t birth_date; ?></td>
            <td><input type="text" name="birth_date" value="<?php echo $birth_date; ?>" />
              <?php if ($error_birth_date) { ?>
              <span class="error"><?php echo $error_birth_date; ?></span>
              <?php } ?></td>
          </tr>
to:

Code: Select all

    <tr>
            <td><span class="required">*</span> <?php echo $entry_t birth_date; ?></td>
            <td><input type="text" name="birth_date" value="<?php echo $birth_date; ?>" size="12" id="dob" />
              <?php if ($error_birth_date) { ?>
              <span class="error"><?php echo $error_birth_date; ?></span>
              <?php } ?></td>
          </tr>
Then, at the end of this file, add the following before the footer:

Code: Select all

<script type="text/javascript" src="catalog/view/javascript/jquery/ui/ui.datepicker.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
    $('#dob').datepicker({changeMonth: true, changeYear: true, yearRange: '-80:+0', dateFormat: 'yy-mm-dd'});
});
//--></script>

Re: Birth date - registration form

Posted: Mon Aug 02, 2010 5:58 pm
by Codenamechicken
Small error here:

Code: Select all

<tr>
            <td><span class="required">*</span> <?php echo $entry_t birth_date; ?></td>
            <td><input type="text" name="birth_date" value="<?php echo $birth_date; ?>" />
              <?php if ($error_birth_date) { ?>
              <span class="error"><?php echo $error_birth_date; ?></span>
              <?php } ?></td>
</tr>
should be

Code: Select all

<tr>
            <td><span class="required">*</span> <?php echo $entry_birth_date; ?></td>
            <td><input type="text" name="birth_date" value="<?php echo $birth_date; ?>" />
              <?php if ($error_birth_date) { ?>
              <span class="error"><?php echo $error_birth_date; ?></span>
              <?php } ?></td>
</tr>

Re: Birth date - registration form

Posted: Sun Aug 29, 2010 2:26 am
by silanli_53
How can I see the admin panel..?



Thanks
best regarts

Re: Birth date - registration form

Posted: Wed Jan 26, 2011 3:55 pm
by ocnewby
I was doing the edits , and altho it was displaying the text entry box properly, in mySQL there was no birthdate being saved.

I didnt know what
"and remeber change editCustomer() and editCustomer in catalog\model\account\customer.php"
meant.
I figured it out. It means to edit that file and change the line to include the birth_date field insert.

$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET store_id = '" . (int)$this->config->get('config_store_id') . "', birth_date = '" . $this->db->escape($data['birth_date']) . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', password = '" . $this->db->escape(md5($data['password'])) . "', newsletter = '" . (int)$data['newsletter'] . "', customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "', status = '1', date_added = NOW()");

Once i did that the "customers" sql table now includes the birth_date field properly filled in.

Re: Birth date - registration form

Posted: Sat Jan 29, 2011 11:14 am
by ocnewby
Let me just state that if you add fields like birth_date to the database then that leaves you with problems when db revisions come in subsequent OC releases. But this is a test setup so I don't mind messing it up.

Once the mySQL tables are being properly updated you will not see the birthdate field being displayed anywhere in OC.

To add the view to the admin panel you must make a number of edits.

have to edit
system/library/customer.php

after private $address_id;
add private $birth_date;

after $this->fax = $customer_query->row['fax'];
add $this->birth_date = $customer_query->row['birth_date'];

after $this->fax = $customer_query->row['fax'];
add $this->birth_date = $customer_query->row['birth_date'];

after $this->fax = '';
add $this->birth_date = '';

after public function getTelephone() {
return $this->telephone;
}

add public function getBirth_date() {
return $this->birth_date;
}
--
store/admin/view/template/sale/customer_form.tpl
edit:

after <table class="form">


add

<tr>
<td><?php echo $entry_birth_date; ?></td>
<td><input type="text" name="birth_date" value="<?php echo $birth_date; ?>" /></td>
</tr>

===

/admin/controller/sale/customer.php


after $this->data['entry_fax'] = $this->language->get('entry_fax');
add $this->data['entry_birth_date'] = $this->language->get('entry_birth_date');


after if (isset($this->request->post['fax'])) {
$this->data['fax'] = $this->request->post['fax'];
} elseif (isset($customer_info)) {
$this->data['fax'] = $customer_info['fax'];
} else {
$this->data['fax'] = '';
}

add if (isset($this->request->post['birth_date'])) {
$this->data['birth_date'] = $this->request->post['birth_date'];
} elseif (isset($customer_info)) {
$this->data['birth_date'] = $customer_info['birth_date'];
} else {
$this->data['birth_date'] = '';
}


===
/admin/language/english/sale/customer.php


$_['entry_fax'] = 'Fax:';
$_['entry_birth_date'] = 'Birth_date:';


= = = = = =

Please note that these edits don't allow you to correct an incorrect birthdate entry. It will only allow you to view what was input into the table previously.
To make edits from the customer view in admin you would have to edit the sql statement in model to include an UPDATE for the corrected entry.

WHew! that was fun. :crazy:

Re: Birth date - registration form

Posted: Mon Jan 31, 2011 6:22 pm
by bajaber
Great! Am going to try this tonight.

Re: Birth date - registration form

Posted: Tue Feb 22, 2011 9:19 pm
by AndreasG
The above code.
If I want to use three fields instead of one, select box for Year, Month and Day, how would you modify it then?

Thanks!

Andreas

Re: Birth date - registration form

Posted: Sun Apr 17, 2011 2:55 pm
by oliviargi
thanks i will try this

Re: Birth date - registration form

Posted: Fri Apr 22, 2011 2:53 am
by Lamiaa
fido-x
u r great :)
I was looking for this solution to add delivry date in my form.. I tried alot for a week to know how to add pop up datepicker but I didn't understand how to implement it from jquiry site or any other sites, specially I'm beginner and I'm not proggrammer , I just own a website using this great and fabouls Opencart by my webdesigner but he suddenly dissappeared so that I should make every thing by my self. also at first I tried your solution but by adding the code of the javascript in admin coupon form for start and end date with replacing start date to deliverydate and deleting the line for end date but it didn't work. I don't know why but with yor code it works well with me, may be because another codes in admin page.
you don't know how much I appreciate this post

proudly the result appear here:
http://limaregygifts.com/index.php?rout ... est_step_2

by the way just a note for people who serches like me for such tool , it should changed in files as Codenamechicken ,ocnewby and alex.lin said and also in model files.
thaaanx alot for all who really help

Re: Birth date - registration form

Posted: Tue Jul 05, 2011 12:25 am
by enzoprinting
i would like to put 2 more rows and i don't understand how. i need to put a field (not req.) 13 numbers after "Last Name" and field "VAT Reg. ID"(not req if not company). how can i do this?

thanks

Re: Birth date - registration form

Posted: Fri Jan 06, 2012 5:21 am
by Angelheart29
Hello,

I'm working on a website and i wanted to add datepicker on registration form.

I follow the steps above (fido), but the calendar doesn't appear... I have modified links, js, css and other... But nothing.

I'm working with Opencart 1.5.1.3

Any Idea ?

Re: Birth date - registration form

Posted: Mon Jan 09, 2012 11:26 pm
by straightlight
Here's a VQMod version of this.

From PHPMyAdmin, in the SQL tab under your OpenCart database, use the following query:

Code: Select all

ALTER TABLE oc_customer ADD dob VARCHAR(16) NOT NULL;
Note: Change: oc_ to the appropriate prefix name if invalid.

Re: Birth date - registration form

Posted: Tue Jan 10, 2012 12:16 am
by straightlight
Some corrections were made from my XML above. Those who downloaded before will need to re-download it.

Re: Birth date - registration form

Posted: Tue Jan 17, 2012 10:35 pm
by maurotto
straightlight wrote:Some corrections were made from my XML above. Those who downloaded before will need to re-download it.
hi
i get this error in vqmod.log

REQUEST URI : /index.php?route=account/register
DOM UNABLE TO LOAD: /home/mhd-01/www.xxxx.com/htdocs/vqmod/xml/customers_birthday.xml
----------------------------------------------------------------------


---------- Date: 2012-01-17 15:32:54 ~ IP : ----------
REQUEST URI : /index.php?route=information/contact/captcha
DOM UNABLE TO LOAD: /home/mhd-01/www.xxxx.com/htdocs/vqmod/xml/customers_birthday.xml
----------------------------------------------------------------------


---------- Date: 2012-01-17 15:32:54 ~ IP : ----------
REQUEST URI : /index.php?route=account/register/zone&country_id=105&zone_id=
DOM UNABLE TO LOAD: /home/mhd-01/www.xxxx.com/htdocs/vqmod/xml/customers_birthday.xml
----------------------------------------------------------------------


---------- Date: 2012-01-17 15:33:03 ~ IP : ----------
REQUEST URI : /index.php?route=account/register
DOM UNABLE TO LOAD: /home/mhd-01/www.xxxx.com/htdocs/vqmod/xml/customers_birthday.xml
----------------------------------------------------------------------


---------- Date: 2012-01-17 15:33:04 ~ IP : ----------
REQUEST URI : /index.php?route=information/contact/captcha
DOM UNABLE TO LOAD: /home/mhd-01/www.xxxx.com/htdocs/vqmod/xml/customers_birthday.xml
----------------------------------------------------------------------


---------- Date: 2012-01-17 15:33:04 ~ IP : ----------
REQUEST URI : /index.php?route=account/register/zone&country_id=105&zone_id=
DOM UNABLE TO LOAD: /home/mhd-01/www.xxxx.com/htdocs/vqmod/xml/customers_birthday.xml
----------------------------------------------------------------------

Re: Birth date - registration form

Posted: Tue Jan 17, 2012 10:41 pm
by straightlight
Are you using other XML files that requires modifications to the registration page ?

Re: Birth date - registration form

Posted: Wed Jan 18, 2012 12:26 am
by maurotto
Yes

Re: Birth date - registration form

Posted: Wed Jan 18, 2012 12:28 am
by straightlight
Possibly a tracking conflict between multiple XML, obviously.

Re: Birth date - registration form

Posted: Wed Jan 18, 2012 12:36 am
by maurotto
Ok