Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Add a field to checkout and add to admin

Add a field to checkout and add to admin

Views: 783

Results 1 to 4 of 4
30 Jan 2014, 8:24 PM
#1
gxlinx01 avatar

gxlinx01

New Zenner

Join Date:
Mar 2011
Posts:
24
Plugin Contributions:
0

Add a field to checkout and add to admin

I followed Absolute's post here from a few years ago, and there are a few changes since then, but I have been able to add a simple box to the tpl_checkout_shipping_default.php page and it get input into the database.

My only problem is I can't figure out how do I get this field added to admin/orders.php. Can someone offer a little help?

I added a column to the orders database -- order_find_us

My code changes are the following.

includes/templates/Mytemplates/templates/tpl_checkout_shipping_default.php Line 33:

<fieldset class="shipping" id="find_us">
<legend id="checkoutShippingComments">What brought you here?</legend>
<div id="checkoutDropdown">
<select name="find_us">
        <option value="0">Option 1</option>
        <option value="1">Option 2</option>
        <option value="2">Option 3</option>
</select>
</div>
</fieldset>

includes/classes/order.php on line 51

order_find_us,

on line 123

'find_us' => $order->fields['order_find_us'],

on line 363

'find_us' => $_SESSION['find_us'],

on line 643

'order_find_us' => $this->info['find_us'],

on line 134, includes/modules/pages/checkout_shipping/header_php.php

if (isset($_SESSION['find_us'])) {
    $find_us = $_SESSION['find_us'];
  }

online 144

if (zen_not_null($_POST['find_us'])) {
      $_SESSION['find_us'] = zen_db_prepare_input($_POST['find_us']);
    }
    $find_us = $_SESSION['find_us'];

on line, admin/orders.php

              <tr>
                <td class="main"><strong>Reason for Order:</strong></td>
                <td class="main"><?php echo $order->info['order_find_us']; ?></td>
              </tr>

Like I said the information gets put into the database, but when I initiate the code on orders.php the information doesn't show up. I am guessing I am either not initiating it correctly or I am typing in the wrong thing.

Can someone help me get this information to show up on my order page?

Thanks

31 Jan 2014, 2:45 AM
#2
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Add a field to checkout and add to admin

Download Twitch List Price from the plugins and review the code, there are step by step instructions that have the answer you seek.

Just replace 'products_list_price' with the name of YOUR new field 'order_find_us'.

You've almost got it :)

31 Jan 2014, 8:28 PM
#3
gxlinx01 avatar

gxlinx01

New Zenner

Join Date:
Mar 2011
Posts:
24
Plugin Contributions:
0

Re: Add a field to checkout and add to admin

Thanks Twitchtwo!

As to help others, the hint is you must add the new column you created for the checkout page to the select SQL statement and initialize the column in the admin/includes/class/order.php

on line 33, i added the order_find_us column to the select

on line 79, i added order_find_us to the array

'order_find_us' => $order->fields['order_find_us'],

And it shows up on orders.php.

THANKS FOR THE HELP

31 Jan 2014, 8:36 PM
#4
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Add a field to checkout and add to admin

Glad it's working for you :)