Products     Magento Extension     PCI-Shopping-Carts     Templates       CRELoaded     WordPress Modules     osCommerce Modules       osCommerce Addons       osCommerce Features       osCommerce Management       Payment Modules     CRELoaded Modules       CRE Loaded Addons       CRE Loaded Features       CRE Loaded Management       Payment Modules       CRELoaded Services
Free Stuff
Customization
Templates
Compare Products
You have no items to compare.
Affiliate Info
Affiliate Program FAQ
Affiliate Log In
Recent Orders
Hot Keywords: Order Notification, Order Search, Coupon, Flash Board, Compare, Floating Message, Tracking, Moneris, RSS, Visitor Filter

  Add text box to checkout like comments

The following osCommerce contribution is a free Opensource code originated from official osCommerce website and provided for your reference only, you may download the original contribution file(s) and install it on your own; or you may request a Paid Installation Service from Agents Of Power; Agents Of Power does the "AS IS" installation on your website, we do not guarantee it will work properly on your website. Extra Paid service is available for repairing the problem from the original contribution or from your website.
There is a problem width zip file.
Please download this one or copy full instructions
«««««««««««««««««««««««««««««««««««««««««««««
«««««««««««««««««««««««««««««««««««««««««««««
«««««««««««««««««««««««««««««««««««««««««««««
###################################


Add additional "comment" boxes
to the checkout process and emails


###################################


by Anthony Scott
10 Feb 2007
E-Mail: niagol@blackclaws.com


A contribution for osCommerce 2.2 Milestone 2;
released under GNU GENERAL PUBLIC LICENSE


###################################

What this contribution does
###################################


This allows you to add additional text boxes to the checkout process exactly like the comments box.
It does require that you edit your database so the information can be added to the emails.
It does not currently show up in the administration order viewing, haven't gotten that far yet.
These instructions do not include any editing for beauty. If you want to place the box somewhere else or add text to it, go for it but I just put down the bare minimums to add a new box to the check out section and get it into the email.

###################################

Files Affected
###################################

Please backup all files!

1. catalog/checkout_shipping.php
2. catalog/checkout_payment.php
3. catalog/checkout_confirmation.php
4. catalog/checkout_process.php

###################################

Instructions - how to install
###################################

Please backup all files!


##############################changes to make to site:###################################


1. in the file catalog/checkout_shipping.php look for:

if (!tep_session_is_registered('comments')) tep_session_register('comments');
if (tep_not_null($HTTP_POST_VARS['comments'])) {
$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
}

and add below it (you can change the text in caps to reflect your own variable):

if (!tep_session_is_registered('YOUR_NEW_BOX')) tep_session_register('YOUR_NEW_BOX');
if (tep_not_null($HTTP_POST_VARS['YOUR_NEW_BOX'])) {
$YOUR_NEW_BOX = tep_db_prepare_input($HTTP_POST_VARS['YOUR_NEW_BOX']);
}


Also in the same file near the end find:

<tr>
<td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>
</tr>

And above it place

<tr>
<td class="main"><?php echo tep_draw_input_field('YOUR_NEW_BOX', '', 'SIZE=10 maxlength=10') . tep_draw_separator('pixel_trans.gif', '5', '1'); ?></td>
</tr>

------------------------------------------------------

2. In the file catalog/checkout_payment.php look for:

IMPORTANT:
Find:

if (!tep_session_is_registered('comments')) tep_session_register('comments');

and below it add (correct comment - don't lose comment from checkout_shipping.php):

if (tep_not_null($HTTP_POST_VARS['comments'])) {
$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
}

and again below it add (new comment)

if (!tep_session_is_registered('YOUR_NEW_BOX')) tep_session_register('YOUR_NEW_BOX');
if (tep_not_null($HTTP_POST_VARS['YOUR_NEW_BOX'])) {
$YOUR_NEW_BOX = tep_db_prepare_input($HTTP_POST_VARS['YOUR_NEW_BOX']);
}


Find:
<td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>
</tr>

Replace by (correct comment - don't lose comment from checkout_shipping.php):

<td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', $comments); ?></td>
</tr>



and below it place

<tr>
<td class="main"><?php echo tep_draw_input_field('YOUR_NEW_BOX', '', 'SIZE=10 maxlength=10') . tep_draw_separator('pixel_trans.gif', '5', '1') . 'Your text here'; ?></td>

</tr>

------------------------------------------------------

3. in the file catalog/checkout_confirmation.php find:

if (!tep_session_is_registered('comments')) tep_session_register('comments');
if (tep_not_null($HTTP_POST_VARS['comments'])) {
$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
}

and below it place:

if (!tep_session_is_registered('YOUR_NEW_BOX')) tep_session_register('YOUR_NEW_BOX');
if (tep_not_null($HTTP_POST_VARS['YOUR_NEW_BOX'])) {
$YOUR_NEW_BOX = tep_db_prepare_input($HTTP_POST_VARS['YOUR_NEW_BOX']);
}



Find:

<tr>
<td class="main"><?php echo nl2br(tep_output_string_protected($order->info['comments'])) . tep_draw_hidden_field('comments', $order->info['comments']); ?></td>
</tr>

Below it add:

<tr>
<td class="main"><?php echo nl2br(tep_output_string_protected($order->info['YOUR_NEW_BOX'])) . tep_draw_hidden_field('YOUR_NEW_BOX', $order->info['YOUR_NEW_BOX']); ?></td>
</tr>



Find:

<?php
if (tep_not_null($order->info['comments'])) {
?>

Replace by:
<?php
// if (tep_not_null($order->info['comments'])) {
?>

Find (about 20 - 30 lines below last correction):
<?php
}
?>

Replace by:
<?php
// }
?>



---------------------------------------------------

4. In file catalog/checkout_process.php find:


'comments' => $order->info['comments']);

And replace it with

'comments' => $order->info['comments'],
'YOUR_NEW_BOX' => $order->info['YOUR_NEW_BOX']);


Next, in the same file find:

tep_session_unregister('comments');

and below it place:

tep_session_unregister('YOUR_NEW_BOX');



Find:

if ($order->info['comments']) {
$email_order .= tep_db_output($order->info['comments']) . "nn";
}

and below it add

if ($order->info['YOUR_NEW_BOX']) {
$email_order .= tep_db_output($order->info['YOUR_NEW_BOX']) . "nn";
}




-----------------------------------------------------------
5. In file catalong/includes/classes/order.php find:

'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''));

and change it to:

'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''),
'YOUR_NEW_BOX' => (isset($GLOBALS['YOUR_NEW_BOX']) ? $GLOBALS['YOUR_NEW_BOX'] : ''));



---------------------------------------
7. DO NOT FORGET TO DO THIS PART - SQL

Use your friendly database editor (phpMyAdmin, etc) to navigate to the orders_status_history table and add a field with the same name you chose for YOUR_NEW_BOX, it should be set type as text, null as YES and default as NULL, basically whatever you see your comments field is set to, do the same.

---------------------------------------
8. See the NEW commnet in Admin / Orders

Find:

<td class="smallText">' . nl2br(tep_db_output($orders_history['comments'])) . ' 


and below it place:

<br />' . nl2br(tep_db_output($orders_history['YOUR_NEW_BOX'])) . ' 

###################################

Hints
###################################

This is an easy contribution, but watch those single quotes and 'white spaces'. If you have an error because of this fix, you should start there. Also make sure you edit your database BEFORE trying to do an order with the updated code.


Thats it. Your Done!



###################################

Feel free to send me comments, corrections, feedback to:

niagol@blackclaws.com
###################################
I corrected some little bugs and had the possibilitie to see NEW comments in Admin / Orders.
FULL INSTRUCTIONS
   Posted on: 02/03/2009     See contribution details Request Installation with Paid service