Forums / General Questions / Looking for Help Converting the Date of Birth mod to a Wedding Date Mon on Sign Up

Looking for Help Converting the Date of Birth mod to a Wedding Date Mon on Sign Up

Started by limelites on 7 Jan 2012, 8:43 PM · Views: 1,081

Results 1 to 3 of 3
7 Jan 2012, 8:43 PM
#1
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Looking for Help Converting the Date of Birth mod to a Wedding Date Mon on Sign Up

I wonder if anyone can see what's wrong with this code?

I've been trying to modify the Date of Birth (Drop Down DOB) mod to use on our sign up page. However, I don't want it to record the customers date of birth, I want it to record their wedding date.

I'm getting there with it but I've had to disable it for now as there's a coding error that prevents customers registering.

I've got it installed and everything but since it's a DOB mod the dates were in the drop down menu from today, going backwards in time. I traced this to a line in /includes/functions/extra_functions/functions_dob.php:

$today = getdate();
$first_year = 1901;
$last_year = $today['year'];

Changing the line to this corrects the date sequence:

$today = getdate();
$first_year = $today['year'];
$last_year = 2050;

It looks right now but it doesn't function right as it prevents the registration. Obviously something in the code is telling it to expect a DOB so future date's are causing it some sort of logic problem. Can anyone see what else I'd need to change so that it looks for future dates instead of past dates?:

<?php
//
// +----------------------------------------------------------------------+
// | Pull Down DOB menu for zen-cart 1.3x         Open Source E-commerce  |
// +----------------------------------------------------------------------+
// | Copyright (c) 2006 Jeff Dripps (Interactive Sports Entertainment)    |
// | [email protected]                                              |
// |                                                                      |
// |                                                                      |
// |                                                                      |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE.txt, and is    |
// | available through the world-wide-web at the following url:           |
// | http://www.gnu.org/licenses/gpl.txt                                  |
// +----------------------------------------------------------------------+
// $Id: functions_dob.php,v 0.1 2006/04/27 15:46:12 JTD

function zen_draw_pull_down_dob_menu($dob_raw) {
$dob_day = array();
$dob_month = array();
$dob_year = array();

$dob_day[] = array('id' => sprintf('%02d', 0), 'text' => 'day');
$dob_month[] = array('id' => sprintf('%02d', 0), 'text' => 'month');
$dob_year[] = array('id' => sprintf('%02d', 0), 'text' => 'year');

for ($i=1; $i<32; $i++) {
$dob_day[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
}

for ($i=1; $i<13; $i++) {
$dob_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));
}

$today = getdate();
$first_year = $today['year'];
$last_year = 2100;

for ($i=$first_year; $i <= $last_year; $i++) {
$dob_year[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
}

if (!isset($dob_raw)) {
    $dob_year_val = 0;
    $dob_month_val = 0;
    $dob_day_val = 0;
}
else {
    $dob_year_val = (int)substr(zen_date_raw($dob_raw), 0, 4);
    $dob_month_val = (int)substr(zen_date_raw($dob_raw), 4, 2);
    $dob_day_val = (int)substr(zen_date_raw($dob_raw), 6, 2);
}

if (DOB_FORMAT_STRING == 'mm/dd/yyyy') {
    echo zen_draw_pull_down_menu('dob_month', $dob_month, $dob_month_val, 'id="dob_month"');
    echo zen_draw_pull_down_menu('dob_day', $dob_day, $dob_day_val, 'id="dob_day"');
}
else {
    echo zen_draw_pull_down_menu('dob_day', $dob_day, $dob_day_val, 'id="dob_day"');
    echo zen_draw_pull_down_menu('dob_month', $dob_month, $dob_month_val, 'id="dob_month"');
}
echo zen_draw_pull_down_menu('dob_year', $dob_year, $dob_year_val, 'id="dob_year"');
}
?>
7 Jan 2012, 10:55 PM
#2
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Looking for Help Converting the Date of Birth mod to a Wedding Date Mon on Sign Up

Looking at this line in the above file:

for ($i=$first_year; $i <= $last_year; $i++) {
$dob_year[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
}

Can't seem to figure out how to tell it that the date should be a future date. I've tried this:

for ($i=$last_year; $i <= $first_year; $i++) {
$dob_year[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
}

Swapping $last with $first just makes the date drop down blank. Can anyone see what syntax I need to change here? I've tried several hit & miss changes but they either make the year drop down blank, or make the whole site white page :no:

7 Jan 2012, 11:31 PM
#3
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Looking for Help Converting the Date of Birth mod to a Wedding Date Mon on Sign Up

Never mind, I've figured this out. It was actually a missing line in another file. It's working now as I want it. Onto the next part of the puzzle now, how to add this new "wedding date" to all new order confirmation emails and how to add it to the customer panel at the right hand side of the screen in /admin/customers.php?page=1&cID=XXXX