Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2012
    Posts
    8
    Plugin Contributions
    0

    Default 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:

    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?

  2. #2
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,267
    Plugin Contributions
    3

    Default 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. #3
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,021
    Plugin Contributions
    3

    Default Re: Adding textfield and radiobuttons on payments page


  4. #4
    Join Date
    Apr 2012
    Posts
    8
    Plugin Contributions
    0

    Default 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.

 

 

Similar Threads

  1. Out of stock attributes showing with radiobuttons
    By Datax in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 9 Feb 2015, 11:04 AM
  2. Replies: 0
    Last Post: 17 Aug 2012, 02:54 PM
  3. Adding Page 2, Page 3 and Page 4 links to Information Box
    By MillenniumJim in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 16 Feb 2012, 07:47 AM
  4. No payments offered and stuck on shipping page
    By Pet Herbal Remedies in forum Built-in Shipping and Payment Modules
    Replies: 22
    Last Post: 3 Feb 2011, 09:47 PM
  5. Textfield for categories?
    By heatherlsi in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 22 Jan 2009, 06:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg