Forums / Templates, Stylesheets, Page Layout / Adding textfield and radiobuttons on payments page

Adding textfield and radiobuttons on payments page

Views: 620

Results 1 to 4 of 4
3 Apr 2012, 4:44 AM
#1
uentity avatar

uentity

New Zenner

Join Date:
Apr 2012
Posts:
8
Plugin Contributions:
0

Adding textfield and radiobuttons on payments page

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:

<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

$_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

'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

'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

'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?

3 Apr 2012, 9:24 AM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Adding textfield and radiobuttons on payments page

I believe there is a "how did you hear about us" feature in zencart ...

Does it not suit your needs?

20 years a Zencart User

3 Apr 2012, 1:00 PM
#4
uentity avatar

uentity

New Zenner

Join Date:
Apr 2012
Posts:
8
Plugin Contributions:
0

Re: Adding textfield and radiobuttons on payments page

Hi,

I did come across this when I was searching, but as I understand it, it places the "How did you hear about us" form on the Register page. I'll need this on the payment page.

Also, part of what is causing the head scratching here is that some of these radiobuttons initialize textfields.

Perhaps I'll fish around a little and see if nothing else I can apply some of that code to what I'm doing.