Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help please - Add text fields at checkout


dino705

Recommended Posts

I need to add additional text fields at checkout. I've searched the forums and the contributions for hours but can't find any help. I can't add the fields to the profile since the information would be different with each sale. I need to add 4 fields, so that the buyer can enter additional personal information based on the particular sale and that information would be sent to the store owner. Also the entries in the fields would be required for the sale to proceed. Any help would be greatly appreciated. I'm about ready to tell my client to give-up on osCommerce, its way too difficult to configure. Thanks.

Link to comment
Share on other sites

I'm about ready to tell my client to give-up on osCommerce, its way too difficult to configure. Thanks.

 

... and you would turn off a brilliant masterpiece than!

 

I am an absolute noob to php and managed with fair knowledge of codeing in general and same db experience to set up a nicely customized shop. thx to the developers the community and everybody dedicated tothis project.

 

to sum up what you wanna do

 

some extra fields like "put the individual code supplied by post here" ... and make the field obligiatory?

 

in general I think the proces would be to check where to store these values in the db and alter/create the appropriate tables

 

than make the changes in checkout_confirmation.php

 

there is something similar or lets say a basis you could start off with wich is a german contribution that forces you to check a box before confirming like yeah read the conditions

 

so in general instead of a checkbox you need inputfields adn blablabla

 

be carefull not to hard code, as you loose session

 

I generally do for thinks like this A) backup backup backup

than look in other files and contrib/includes and start to try and error

 

if I had a fair knowledge of php I might have spent half time, as I started from = according php. but I think that you will not find any othe solution that is as flexible, cutomizeable and most imortant running dunno on how many live shops with a super support here in the board

 

think twice of dropping osc, you will look around, test others and spend time for nothing, in the end all here will be glad to rewelcome you to the community

 

have fun and don't be shy to test

happy osC-ing

dahui

Link to comment
Share on other sites

http://www.oscommerce.com/community/contributions,2497

 

and

 

http://www.oscommerce.com/community/contributions,1855

 

These contributions add extra lines. You can mod them to be what you want them to be!

 

see I told ya, anything goes adn quite often faster than you believed ;-)

 

thx brian, didn't know them yet but there is too many to knwo them all

 

dahui

Link to comment
Share on other sites

Hi-

Unfortunately, the two contibutions you mention don't do what my client needs. These contributions just modify the address book. As I said in my first post, I need something so that the buyer adds information at checkout. Using these contributions to accomplish what my client needs, the buyer would have to go back and modify his address book every time he checked out, which is a pain. I need to find some way to add the 4 fields during checkout, for example by adding the fields to a modified shipping page or even the confirmation page. The buyer would enter the data (which needs to be required) in the text fields, stored in the database for the store owner, and that data would be carried though the sale and added to the confirmation email the buyer receives. The data would not be stored in the profile or address book. The data would be part of that particular order's information. Any other ideas?

 

By the way, I still have to disagree with those who think this is such a great program. After spending about 11 hours on this one problem, I couldn't recommend osCommerce to anyone except a professional php programmer. Not enough built-in modification ability and way too difficult to modify otherwise (As evidenced by this huge user forum we're in right now. Just look at the number of posts from people who are having trouble or who are trying to modify the program to do something it should do but doesn't!!). Just my two cents. :)

 

Thanks.

Link to comment
Share on other sites

I so want to say goodbye....

but I am nice so I instead I will say that what you want to do is very possible.

 

If you can not figure out how to do it you could get a contribution that is close to what you want and alter it to your needs.

 

Just because a contribution is written for a particular page doesn't mean it can't be altered a bit to be used on a totally different area.

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Thanks for your answer. I agree that the contributions can be modified, if someone knows enough php to do it. But I dont. My original post was to hopefuuly get someone to help me to do it. As I said, after 11 hours of trying to work the code myself, I was hoping someone could be of assistance or could at least point me in the right direction.

Link to comment
Share on other sites

Hello, Alan-

I tried that contribution, but as best as I could tell it adds the additional fields into each additional product rather than for the whole sale. But maybe I don't understand how it works.

Link to comment
Share on other sites

I see what you mean now. Something like a basic "Additional Instructions" text box the customer can complete if they need to and tied to the order (in the db).

 

I had a quick scan of the contibutions but didn't find anything. Doesn't mean there isn't one though.

 

There's a couple there that could be changed pretty easily to do it. I'll look into that, it's a useful feature that is common elsewhere.

Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux

Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)

Link to comment
Share on other sites

Thank you!!Thank you!!Thank you!! Somebody finally understands what I need! That's it: additional fields of information, which they must fill in to complete the order, and could be different next time they order. I searched too and I can't believe there is no contribution for what seems to be a very useful and very needed addition. It's probably really simple for someone who really knows php.

Link to comment
Share on other sites

Thank you!!Thank you!!Thank you!!  Somebody finally understands what I need! That's it: additional fields of information, which they must fill in to complete the order, and could be different next time they order. I searched too and I can't believe there is no contribution for what seems to be a very useful and very needed addition. It's probably really simple for someone who really knows php.

 

Ok, I thought the contributions I mentioned above did that (Their descriptions are a bit vague)

 

One contribution I know adds a field to ALL the address pages create account etc is the customer title dropdown contribution. It should be relatively easy to change it from a dropdown to a textbox (though perhaps a bit tedious)

 

http://www.oscommerce.com/community/contributions,2444

 

I would offer to mod it for you but I've got to wash the car!

Light, in the absence of eyes, illuminates nothing.

Link to comment
Share on other sites

why not modify where the comments field is on checkout, that is tied to the database. then you can create the necessary fields the customer wants (personally on my clients they use the comments box just for this) and they are tied to the order.

on another note, you should ask the store owner to fund you for going to programming classes. do you have any experience at all in programming? sounds like you may be over your head.

anyway, modify just below the comments, best place to put it. if you need different boxes depending upon what the customer purchases, you will have to look for the products they purchase and then add 1, 2, 3, 4 lines from what i have read. what happens if they buy product 1 which requires 4 lines and product 3 which requires 2 lines? how will you handle that?

Link to comment
Share on other sites

Thanks for your reply, b monster. Don't blame you for washing your car. I rather be doing that then still trying to figure this out. The problem with all these contributions, for my needs, is that they attach the additional information to the BUYER, either profile or address book or to the individual PRODUCT. What I need is someway to attach the additional information to the ORDER table at checkout and the confirmation emails. I've added fields to the ORDER table in mySQL, but I can't figure out how osCommerce inserts or retrieves data to the db and I can't find any documentation that tells you. It doesn't use straightforward php insert or select code, which i know how to do.

Link to comment
Share on other sites

Just read your previous posts again and it seems that I have got the wrong idea of what it is that you want.

 

It's nothing about modifying the customer details at all.

 

I'll have a look and see if I can find some snippits of code to help you.

 

Do you need these fields for each product in an order or just for a whole order. The latter is certainly going to be easier!

 

Have a look at this contribution (imprint text options), it might be more along the lines you are looking for (though I've never used it).

 

http://www.oscommerce.com/community/contributions,2618

Light, in the absence of eyes, illuminates nothing.

Link to comment
Share on other sites

Exactly right! Thank you so much. It's not about modifying the customer details, its about the order. And yes, it's for additional info for the WHOLE order, not the individual items. Similar to the order 'Comments' field. I've tried copying how the program handles shiping Comments, but after working hours I still can't get it to work; it just won't load the info into the new fields in the db for me.

Link to comment
Share on other sites

one thing might help us help you, is for you to help us by posting the code you are using in the comments area. not the whole file but the area where you are adding the additional fields.

you could modify the 'how did you find us' contribution to suit your needs also.

Link to comment
Share on other sites

Ok, here's how to do it! (assuming I remember everything!)

 

This will display 4 textboxes (line1, line2 etc) on checkout_shipping.php and store the info in the orders_status_history table (in fields called line1, line2 etc which you have to create)

 

First create a new php file called additional_info.php (in the catalog directory) and add the following code...

 

<?php
/*

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo TABLE_HEADING_PUT_SOMETHING_HERE; ?></b></td>
         </tr>
       </table></td>
     </tr>
<tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main" width="100%" valign="top"><?php echo TEXT_heading_here; ?></td>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                 <tr>
                   <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                   <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
   <td class="main"><?php echo ENTRY_LINE_1; ?></td>
   <td class="main"><?php echo tep_draw_input_field('line1') . ' ' . (tep_not_null(ENTRY_LINE_1_TEXT) ? '<span class="inputRequirement">' . ENTRY_LINE_1_TEXT . '</span>': ''); ?></td>
 </tr>
 <tr>
   <td class="main"><?php echo ENTRY_LINE_2; ?></td>
   <td class="main"><?php echo tep_draw_input_field('line2') . ' ' . (tep_not_null(ENTRY_LINE_2_TEXT) ? '<span class="inputRequirement">' . ENTRY_LINE_2_TEXT . '</span>': ''); ?></td>
 </tr>
 <tr>
   <td class="main"><?php echo ENTRY_LINE_3; ?></td>
   <td class="main"><?php echo tep_draw_input_field('line3') . ' ' . (tep_not_null(ENTRY_LINE_3_TEXT) ? '<span class="inputRequirement">' . ENTRY_LINE_3_TEXT . '</span>': ''); ?></td>
 </tr>
 <tr>
   <td class="main"><?php echo ENTRY_LINE_4; ?></td>
   <td class="main"><?php echo tep_draw_input_field('line4') . ' ' . (tep_not_null(ENTRY_LINE_4_TEXT) ? '<span class="inputRequirement">' . ENTRY_LINE_4_TEXT . '</span>': ''); ?></td>
 </tr>
</table></td>
                   <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                 </tr>
               </table></td>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
             </table></td>
         </tr>        </table></td>
     </tr>

 

(sorry the indenting is all over the place)

 

Now find in checkout_shipping.php

        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></b></td>

 

and replace with

        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <?php require(DIR_WS_MODULES . 'additional_info.php'); ?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></b></td>

 

Then under

            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_delivery.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>

 

add

<?php
 if ($messageStack->size('checkout_address') > 0) {
?>
     <tr>
       <td><?php echo $messageStack->output('checkout_address'); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 }
?>

 

and below

// process the selected shipping method
 if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') ) {

 

add

 

/*****************Modified by Beer Monster******************/
     $line1 = tep_db_prepare_input($HTTP_POST_VARS['line1']);
     $line2 = tep_db_prepare_input($HTTP_POST_VARS['line2']);
     $line3 = tep_db_prepare_input($HTTP_POST_VARS['line3']);
     $line4 = tep_db_prepare_input($HTTP_POST_VARS['line4']);

//error handling, if textboxes are empty, display a message!
     if (strlen($line1) < ENTRY_LINE_1_MIN_LENGTH) {
       $error = true;

       $messageStack->add('checkout_address', ENTRY_LINE_1_ERROR);
     }

     if (strlen($line2) < ENTRY_LINE_1_MIN_LENGTH) {
       $error = true;

       $messageStack->add('checkout_address', ENTRY_LINE_1_ERROR);
     }
     
     if (strlen($line3) < ENTRY_LINE_1_MIN_LENGTH) {
       $error = true;

       $messageStack->add('checkout_address', ENTRY_LINE_1_ERROR);
     }
     
     if (strlen($line4) < ENTRY_LINE_1_MIN_LENGTH) {
       $error = true;

       $messageStack->add('checkout_address', ENTRY_LINE_1_ERROR);
     }


     if ($error == false) {  //if no errors, write to database!
        
   if (!tep_session_is_registered('line1')) tep_session_register('line1');
   if (!tep_session_is_registered('line2')) tep_session_register('line2');
   if (!tep_session_is_registered('line3')) tep_session_register('line3');
   if (!tep_session_is_registered('line4')) tep_session_register('line4');
   
/*****************End of Modification - Beer Monster******************/

 

In includes/classes/order.php find

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

 

and replace with...

                          'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''),
                         'line1' => (isset($GLOBALS['line1']) ? $GLOBALS['line1'] : ''),
                         'line2' => (isset($GLOBALS['line2']) ? $GLOBALS['line2'] : ''),
                         'line3' => (isset($GLOBALS['line3']) ? $GLOBALS['line3'] : ''),
                         'line4' => (isset($GLOBALS['line4']) ? $GLOBALS['line4'] : ''));

 

in checkout_process.php find

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

 

and replace with

                          'comments' => $order->info['comments'],
                         'line1' => $order->info['line1'],
                         'line2' => $order->info['line2'],
                         'line3' => $order->info['line3'],
                         'line4' => $order->info['line4']);

 

You will have to define the values of the following constants in english.php or in the database.

 

ENTRY_LINE_1 ( 2,3 &4)

TABLE_HEADING_PUT_SOMETHING_HERE

ENTRY_LINE_1_TEXT ( 2,3 &4) (usually just a * to show that it's a required field)

ENTRY_LINE_1_ERROR ( 2,3 &4), an error message to display if the field is not filled.

ENTRY_LINE_1_MIN_LENGTH ( 2,3 &4), the minimum no. of characters the customer must enter

 

Think I've remembered everything. I've used the same process as for the comments field but you could probably change the target table to the orders table if you want. I suggest you get it working first though! Any probs, let me know!!

 

Brian

Light, in the absence of eyes, illuminates nothing.

Link to comment
Share on other sites

I think you are missing his point, he wants to know how to have a customer add additional information to a order on checkout. (ie additional text fields that a customer would fill in with specific information relating to the order not the product).

 

I've been scouring the forums and contributions for weeks trying to find a compromise. I found this thread and have worked with the extra address fields to create new text fields in the create account page which after long hours is looking okay, but ideally I'm thinking I want to create a new table for the additional information, and have the fields show up somewhere in the checkout process. (most likely in the payment section)

 

I'm thinking some kind of Addon that allows for additional fields in checkout? Modify the textarea to text fields in the payment section? Something like product attributes but called checkout attributes? You can have radio buttons, text fields, checkboxes and textareas?

 

Hmmm...

Link to comment
Share on other sites

Hi, b Monster-

Tried your code. Am getting a parse error on checkout_shipping. php:

"Parse error: parse error, unexpected $ in /home/vignet/public_html/clients/checkout_shipping.php on line 603"

 

Line 603 is the last line of code on the page. I'm looking for a missing } or " but haven't found any yet.

 

Any ideas? Thanks.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...