Hi, I'm new to zencart and have been slowly learning php, so please bear with me.
I'm working within a 1.38a version of zencart, it was already setup before I came on to the project, so I'll eventually update and have to do this all over again.
In any case, the customer wants a "How did you hear about us" section listed on the checkout page. It currently has 6 radio buttons, 4 of which display textboxes when they are clicked (via some javascript). I found a post here that was of great help doing this and figured out most of the javascript and verification stuff myself. Since I have two different types of inputs and would like to retain the values of both, I have to pass them along as two separate items in to the database. The problem is that I can't seem to pass the textbox property to the header_php.php page.
I've basically taken every step that was listed in the page I linked to, only I've had to send them as two values. This is the code I have for the form:
PHP Code:
<fieldset>
<legend><?php echo TABLE_HEADING_REFER;?></legend>
<table style="padding-left: 15px;">
<tr><td>Magazine</td>
<td style="padding-left: 15px;"><input id="radio" type="radio" name="refer_btn" value="Magazine" onclick="noshow()" /></td>
<td></td>
</tr>
<tr><td>Web Search</td>
<td style="padding-left: 15px;"><input id="radio" type="radio" name="refer_btn" value="Web Search" onclick="noshow()" /></td>
<td></td>
</tr>
<tr><td>Friend</td>
<td style="padding-left: 15px;"><input id="radio" type="radio" name="refer_btn" value="A Friend" onclick="rad1()" /></td>
<td><span id="check1">You're friend's name?:<?php echo zen_draw_input_field('refer_box'); ?></span></td>
</tr>
<tr><td>Blog</td>
<td style="padding-left: 15px;"><input id="radio" type="radio" name="refer_btn" value="Blog" onclick="rad2()" /></td>
<td><span id="check2">Which Blog?:<?php echo zen_draw_input_field('refer_box'); ?></span></td></td>
</tr>
<tr><td>Website</td>
<td style="padding-left: 15px;"><input id="radio" type="radio" name="refer_btn" value="Website" onclick="rad3()" /></td>
<td><span id="check3">Which Website?:<?php echo zen_draw_input_field('refer_box'); ?></span></td>
</tr>
<tr><td>Other</td>
<td style="padding-left: 15px;"><input id="radio" type="radio" name="refer_btn" value="Other" onclick="rad4()" /></td>
<td><span id="check4">Where?:<?php echo zen_draw_input_field('refer_box'); ?></span></td></tr>
</table>
</fieldset>
I've placed this in the pages/checkout_confirmation/header_php.php file
PHP Code:
$_SESSION['refer_btn'] = zen_db_prepare_input($_POST['refer_btn']);
$_SESSION['refer_box'] = zen_db_prepare_input($_POST['refer_box']);
if ($_SESSION['refer_btn'] == '') {
$messageStack->add_session('checkout_payment', 'Please tell us how you heard about us before proceeding.', 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
Then I've placed these codes in includes/classes/order.php
line 54, I've added order_refer and order_refer_detail to the SQL statement
line 123
PHP Code:
'refer_btn' => $order->fields['order_refer'],// this line is for extra field in checkout page
'refer_box' => $order->fields['order_refer_detail'],// this line is for extra field in checkout page
line 356
PHP Code:
'refer_btn' => $_SESSION['refer_btn'],// extra field in checkout page
'refer_box' => $_SESSION['refer_box'],// extra field in checkout page
and finally on line 618
PHP Code:
'order_refer' => $this->info['refer_btn'],// for extra field in checkout page
'order_refer_detail' => $this->info['refer_box'],// for extra field in checkout page
the 'refer_btn' value is coming through, but for some reason the 'refer_box' is not passing to the database. Does anyone know why this might be?