Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add fields at checkout: someone PLS help...


TerryK

Recommended Posts

I know there must be an answer to this, but two days of searching through 200+ pages of 'relevant' posts has only resulted in lots of questions, but no answers. And I'm getting desperate :(

 

I need to add a couple of custom fields to my checkout page: one to get a customer to advise how they want backorders handled if part of their order is out of stock. A simple checkbox with two options, or radio buttons, would work for that.

 

The other needs to be a combination of radio buttons, dropdown list and text field for a customer to choose:

 

1. Gift card type (birthday, new baby, Christmas, etc.) - dropdown

2. Recipient name - text

3. Gender - radio

4. Gift message - text

 

I tried to install the giftwrap contrib ( unsuccessful because I've made so many changes to my checkout layout that I couldn't figure out where some bits went -- not to mention that a flu bug has declared victory over my brains the past few days! ), but it also didn't seem to offer what I need as relates to dropdowns and radio buttons.

 

I saw a contrib for 'accept terms' which might help with the first checkbox need, but still doesn't address the radio buttons and text issues.

 

In my search for answers this weekend, I must have come across 50+ posts where people asked for help with similar needs, but no responses. Is it really that difficult to add fields to, say, checkout_shipping.php, and have them carry through the balance of the order? If I knew how to start, I could probably work it the rest of the way through, but I don't know how to get it going. Or, if it really IS close to impossible, can someone in the know let ME know so I can give up and move on to something more productive?

 

I would gladly commit to writing out the instructions and posting them for posterity to all members if someone could give me a hand. Anyone? Please, please, pretty please?

 

TIA,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Hi Terry,

 

Sorry to hear you have had such a hard time trying to get answers. It seems, as a broad overview, all you want to do is add a few extra form fields, and push the user entered information from these fields back into the database.

 

I will PM you and send a small example of how to do this, but I don't know if it is what you are looking for. If you study something in osC that is quite simple (like 'contact_us.pphp'), you will see how easy it is to add an extra field, dropdwon,etc, and also how to pass the field values to the same PHP script, or call another.

 

Anyway, I'll PM you. :D

 

Peter

Link to comment
Share on other sites

Hi Terry,

 

Letting you know that you're not alone...I've just posted a similar request in relation to adding new fields.

 

I've asked if anyone has created an 'insert' feature to add fields in the admin console.

 

It seems to be possible to do this with new products but not with fields, but maybe...just maybe an avid coder will read and get on to it...

 

If I get a reply I'll keep you informed as this is a real need for me also...

 

Regards

G

Link to comment
Share on other sites

I'm searching for the same thing. I'm building a shop where people can pick up groceries at different locations. I need to make a dropdownlist with locations in the checkout area. These locations have to be shown on the orders. I'm also searching and searching but i haven't found any solution that i can use. I hope peterr can help me too....

 

many thanxs

Link to comment
Share on other sites

Hi,

 

It's often good to 'work backwards' in situations like this.

 

1. Find an osC form where a dropdown is used.

 

2. Find out what includes, functions and other code 'generate' the dropdown.

 

3. You have now worked backwards, to the source of how it is done, there will no doubt be an osC function to do it.

 

I'll have a bit of a look, not too much time, the tax man will be after me if I don't get my return done soon. :D

 

Peter

Link to comment
Share on other sites

Hi,

 

Had a very rough/quick look at this, and threw some instructions together.

 

1. Use a form on your website that has a dropdown (for example, the manufacturers dropdown shown on index.php)

 

2. Do a 'view source' and find where the code is (i.e. search for 'manufacturer').

 

3. Here is the section of code for the manufacturers dropdown:

 

<!-- manufacturers //-->
         <tr>
           <td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
   <td height="14" class="infoBoxHeading"><img src="images/infobox/corner_right_left.gif" border="0" alt="" width="11" height="14"></td>
   <td width="100%" height="14" class="infoBoxHeading">Manufacturers</td>
   <td height="14" class="infoBoxHeading" nowrap><img src="images/pixel_trans.gif" border="0" alt="" width="11" height="14"></td>
 </tr>

</table>
<table border="0" width="100%" cellspacing="0" cellpadding="1" class="infoBox">
 <tr>
   <td><table border="0" width="100%" cellspacing="0" cellpadding="3" class="infoBoxContents">
 <tr>
   <td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="1"></td>
 </tr>
 <tr>
   <td class="boxText"><form name="manufacturers" action="http://example.com/index.php" method="get"><select name="manufacturers_id" onChange="this.form.submit();" size="1" style="width: 100%"><option value="" SELECTED>Please Select</option><option value="1">Casio</option><option value="2">Chiayo</option><option value="3">Epson</option><option value="4">Hitachi</option><option value="5">Mitsubishi</option><option value="6">NEC</option><option value="7">Sanyo</option><option value="8">Tascam</option><option value="9">Telex</option></select></form></td>

 </tr>
 <tr>
   <td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="1"></td>
 </tr>
</table>
</td>
 </tr>
</table>
           </td>
         </tr>

<!-- manufacturers_eof //-->

 

4. Search for the string '<!-- manufacturers //-->' in your osCommerce source code.

 

5. We find one occurance, /catalog/includes/boxes/manufacturers.php

 

6. Build a small script to include the required code.

 

<?php
/*
 $Id: index.php,v 1.1 2003/06/11 17:37:59 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/


//This is just a simple test to see how a dropdown works in osCommerce

//setup the PHP constants from the database
 require('includes/application_top.php');
 
// setup the additional PHP constants needed for the dropdown (and other functions)
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);  

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- build the dropdown box //-->
<?php require('includes/boxes/manufacturers.php');?>

</body>
</html>

 

7. Save the file as 'dropdowntest.php', upload it to your 'catalog' path.

 

8. Run the dropdown test - http://example.com/dropdown.php

 

9. NB: The dropdown has a Javascript 'onChange' event, which will go and retrieve all the products for the manufacturer you select in the dropdown box.

 

10. That's it, study the code in manufacturers.php , and see how the dropdown is built.

 

(i) Simple SQL query to retrive all the rows from the manufacturers table.

(ii) If any rows found, build the dropdown, else no dropdown is built.

(iii) Setup an array, fill the array with all the info required.

(iv) Display the dropdown (especially see the tep_draw_pull_down_menu() function ).

 

Well, these instructions are pretty rough, but it will give you a small simple script to see how a dropdown works. I would suggest you make good use of the PHP 'echo' to display some of the variables and even some of the array elements; it's fun, enjoy it. :D

 

Peter

Link to comment
Share on other sites

Hi,

 

I've read your reply and it's pretty rough. I'm having trouble with how to add the selection you make when you checkout (for instance from a dropdownlist) to your order overview in the admin area. But the first problem is ofcourse the dropdownlist itself. I found a contribution

 

Dropdown Question Box for Create_account screen

 

But this contibution is for adding a box in the create account page. I'm trying to convert it to the checkout page, but i'm affraid I will screw things up( I just started using php mysql a month ago). Maybe somebody can have a look at it so we can help multiple people. I'm going to try some stuff to and if it works i'll post it.

Link to comment
Share on other sites

Hi,

 

I've read your reply and it's pretty rough.

 

Well, I did say it was rough, and besides .............

 

if help = free {
  rough_instructions = true;
} else {
  pay_me_some_$$$ = true;
}

:lol:

 

I'm having trouble with how to add the selection you make when you checkout (for instance from a dropdownlist) to your order overview in the admin area. But the first problem is ofcourse the dropdownlist itself. I found a contribution

 

Dropdown Question Box for Create_account screen

 

But this contibution is for adding a box in the create account page.

 

There are a few discussions on that contribution, try a simple search on string '1888'.

 

I'm trying to convert it to the checkout page, but i'm affraid I will screw things up( I just started using php mysql a month ago).

 

The principles I explained are the same, even if the instructions were 'rough', they are simple. If you are not confident with adding a dropdown to the checkout page, then start with a simple script first, like in the example I have given. Other people have replied already and stated the dropdown instructions helped them a lot, so if you can determine what options you want in the dropdown, then just alter the sql query accordingly. Especially study how osC does dropdowns, as I pointed out in step 10.

 

Peter

Link to comment
Share on other sites

By george, I think I've got it! Woohoo! :) :) :)

 

I've managed to put radio buttons into my checkout_shipping.php page to get customer input on how they want to handle backorders, and then carry that information through the order process and into the Email. (Haven't worked on displaying it on the invoice or other /admin functions yet, but will eventually.)

 

If you want to use this for some other function, you should be able to modify the instructions below to suit your needs. Here goes:

 

1. In database table ORDERS_STATUS_HISTORY, add a new field via PHPmyAdmin:

 

FIELD: backorders

TYPE: text

ATTRIBUTES: (leave blank)

NULL: No

DEFAULT: (leave blank)

EXTRA: (leave blank)

 

 

2. In 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']);
   }

 

Right underneath that, add:

 

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

 

3. Add a new table to display backorder options within the HTML section on checkout_shipping.php. I placed mine above the 'TABLE_HEADING_COMMENTS' area.

 

NOTE: This works on my page, but you may have to adapt the code to fit your layout. (If it falls apart, look for coding errors in the table structure.) Here's my code:

 

      <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="productListing-heading"><b><?php echo HEADING_BACKORDERS; ?></b></td>
         </tr>
     <tr>
       <td ALIGN="center"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>
     </tr>
       </table></td>
     </tr>
             <tr>
               <td COLSPAN="3" class="main" valign="top"><?php echo TEXT_BACKORDERS; ?></tr>
     <tr>
       <td ALIGN="center"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>
     </tr>
    <tr>
              <td class="main"><table border="0" width="100%" cellspacing="1" cellpadding="2">
  	 <tr>
      <td width="10%" class="main" valign="top"><?php echo tep_draw_radio_field('backorders', 'Hold order until all items are in stock.', CHECKED) . '</td><td width="90%" class="main" valign="top">' . HOLD . '</td></tr><tr><td width="10%" class="main" valign="top">' . tep_draw_radio_field('backorders', 'Ship in-stock items now and backordered items as available. Additional shipping charges will apply.') . '</td><td width="90%" class="main" valign="top">' . SHIP . '</td></tr><tr><td width="10%" class="main" valign="top">' . tep_draw_radio_field('backorders', 'Ship in-stock items and cancel any backordered items.') . '</td><td width="90%" class="main" valign="top">' . CANCEL . '</td></tr></table>'; ?></td>
            </tr>
     <tr>
       <td ALIGN="center"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '25'); ?></td>
     </tr>

 

You can move the CHECKED text above to whichever option you want to have selected by default.

 

The part of this text marked in red:

 

"('backorders', 'Hold order until all items are in stock.', CHECKED) . '

 

is the text that will be stored in the 'backorders' field in the ORDERS_STATUS_HISTORY table, and carried forward onto the checkout_confirmation.php page and into the Email. Change it to read what you want.

 

In /catalog/includes/languages/english/checkout_shipping.php, add some defines (I put mine on the line right above the final '?>' at the bottom of the page):

 

define('HEADING_BACKORDERS', 'BACKORDERS');
define('TEXT_BACKORDERS', 'If any of the products you have ordered are listed as being on backorder, or become unavailable prior to your order being processed, please tell us how you would prefer to have your order handled:');

 

In /catalog/includes/languages/english.php, define the text for your radio buttons. Look for:

 

// text for gender
define('MALE', 'Male');
define('FEMALE', 'Female');
define('MALE_ADDRESS', 'Mr.');
define('FEMALE_ADDRESS', 'Ms.');

 

Right underneath it, add:

 

// text for backorders
define('HOLD', 'Hold order until all items are in stock.');
define('SHIP', 'Ship in-stock items now and backordered items (if any) as available. <b>(Additional shipping charges, based on package weight as outlined in our Shipping section, will apply to each shipment.)</b>');
define('CANCEL', 'Ship in-stock items and cancel any backordered item(s).');

 

In /catalog/includes/checkout_process.php, look for:

 

  $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
 $sql_data_array = array('orders_id' => $insert_id,
                         'orders_status_id' => $order->info['order_status'],
                         'date_added' => 'now()',
                         'customer_notified' => $customer_notification,
                         'comments' => $order->info['comments']);
 tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

and replace with:

 

  $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
 $sql_data_array = array('orders_id' => $insert_id,
                         'orders_status_id' => $order->info['order_status'],
                         'date_added' => 'now()',
                         'customer_notified' => $customer_notification,
                         'comments' => $order->info['comments'],
                         'backorders' => $order->info['backorders']);
 tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

Then look for:

 

// lets start with the email confirmation
 $email_order = STORE_NAME . "\n" .
                EMAIL_SEPARATOR . "\n" .
                EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
                EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .
                EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
 if ($order->info['comments']) {
   $email_order .= tep_db_output($order->info['comments']) . "\n\n";
 }
 $email_order .= EMAIL_TEXT_PRODUCTS . "\n" .
                 EMAIL_SEPARATOR . "\n" .
                 $products_ordered .
                 EMAIL_SEPARATOR . "\n";

 

and replace with:

 

// lets start with the email confirmation
 $email_order = STORE_NAME . "\n" .
                EMAIL_SEPARATOR . "\n" .
                EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
                EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .
                EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
 if ($order->info['comments']) {
   $email_order .= tep_db_output($order->info['comments']) . "\n\n";
 }
 $email_order .= EMAIL_SEPARATOR . "\n" .
     EMAIL_TEXT_BACKORDERS . "\n\n" .
tep_db_output($order->info['backorders']) . "\n\n";

 $email_order .= EMAIL_TEXT_PRODUCTS . "\n" .
                 EMAIL_SEPARATOR . "\n" .
                 $products_ordered .
                 EMAIL_SEPARATOR . "\n";

 

Then look for:

 

// unregister session variables used during checkout
 tep_session_unregister('sendto');
 tep_session_unregister('billto');
 tep_session_unregister('shipping');
 tep_session_unregister('payment');
 tep_session_unregister('comments');

 

Replace with:

 

// unregister session variables used during checkout
 tep_session_unregister('sendto');
 tep_session_unregister('billto');
 tep_session_unregister('shipping');
 tep_session_unregister('payment');
 tep_session_unregister('comments');
 tep_session_unregister('backorders');

 

Next, in /catalog/includes/languages/english/checkout_process.php, look for:

 

define('EMAIL_TEXT_PRODUCTS', 'Products');

 

Right above it, add:

 

define('EMAIL_TEXT_BACKORDERS', 'You have selected to handle backordered items (if any) as follows:');

 

In /catalog/includes/checkout_confirmation.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']);
 }

 

Replace with:

 

  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']);

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

 

Then, right underneath the Shipping Method on that page, I remind them of the option they selected for handling backorders. Look for:

 

              <tr>
               <td class="main"><?php echo $order->info['shipping_method']; ?></td>
             </tr>

 

Replace with:

 

              <tr>
               <td class="main"><?php echo $order->info['shipping_method']; ?></td>
             </tr>
             <tr>
               <td class="main"><i><?php echo $order->info['backorders']; ?></i></td>
             </tr>

 

In /catalog/includes/classes/order.php, look for:

 

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

 

replace with:

 

                          'tax_groups' => array(),
                         'backorders' => (isset($GLOBALS['backorders']) ? $GLOBALS['backorders'] : ''),
                         'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''));

 

Okay, I think that's it! Again, you'll need to carefully check your code (especially the HTML aspects) to see if it works for you, but you can see it in action by putting through a test order via my WWW link below.

 

HTH!

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Hi Terry,

 

That's great that you got it to work. Do you use someting like "Beyond Compare" to keep a check on the modifications (i.e. the 'base' version of osC + your mods). Just thinking ahead to when new releases of osC come out.

 

Peter

Link to comment
Share on other sites

I haven't used that so far, Peter -- I rely mainly on notes in my code and when that doesn't work, my (ever-failing) memory. :)

 

When new releases come out, I'll probably run them in test mode and do the updates as needed, based on what features will then be standard.

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

  • 2 weeks later...

guys i have same issue.

i need 2 radio buttons at checkout. they r for extra wrapping paper and not wrapping paper. my client want this way an dcant do anything else.

he needs:

radiobutton1 : wrapp ur products

radiobutton2 : dont wrap.

 

if someone click wraps, 2$ will be added to order, if they choose dont wrap nothing happens. now not all product need that. if the weight is over 10lbs, then give them these 2 radio buttons otherwise not.

any idea?

Link to comment
Share on other sites

Hi,

 

Just a few 'wild' ideas. :D

 

1. Would your client consider using the product attributes (dropdown boxes), because that functionality would fit _almost_ 'like a glove' to how you need 'options', wouldn't it ?

 

2. Use radio buttons, but use the code from the product attributes, to add or not add the $2,etc,etc.

 

Peter

Link to comment
Share on other sites

There is a gift wrap contribution in the Contrib's section that would probably be better suited for your needs. They based it in part on a flat-rate shipping method.

 

HTH,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

From the Readme:

 

A new box is created on the Checkout Shipping Page asking... "Would like to GiftWrap your Order?" There are two options, GiftWrap or No GiftWrap. Each with an associated cost configured in osCAdmin. The GiftWrap amount is applied to the Order and appears on the Checkout Confirmation Page, both in the Shipping Summary and in the Order Totals.

 

Sounds like that's what you're looking for...

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

A search of the Contrib section for Gift wrap only resulted in one option for me... try it. :)

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

  • 7 months later...

Terry,

 

Do you have this in a contribution? I tried it but the email in admin orders, contact_us.php, or receiving an email from the order quit working.

 

Thanks!

 

By george, I think I've got it! Woohoo! :) :) :)

 

I've managed to put radio buttons into my checkout_shipping.php page to get customer input on how they want to handle backorders, and then carry that information through the order process and into the Email. (Haven't worked on displaying it on the invoice or other /admin functions yet, but will eventually.)

 

If you want to use this for some other function, you should be able to modify the instructions below to suit your needs. Here goes:

 

1. In database table ORDERS_STATUS_HISTORY, add a new field via PHPmyAdmin:

 

FIELD: backorders

TYPE: text

ATTRIBUTES: (leave blank)

NULL: No

DEFAULT: (leave blank)

EXTRA: (leave blank)

2. In 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']);
? ?}

 

Right underneath that, add:

 

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

 

3. Add a new table to display backorder options within the HTML section on checkout_shipping.php. I placed mine above the 'TABLE_HEADING_COMMENTS' area.

 

NOTE: This works on my page, but you may have to adapt the code to fit your layout. (If it falls apart, look for coding errors in the table structure.) Here's my code:

 

 ? ? ?<tr>
? ? ? ?<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
? ? ? ? ?<tr>
? ? ? ? ? ?<td class="productListing-heading"><b><?php echo HEADING_BACKORDERS; ?></b></td>
? ? ? ? ?</tr>
? ? ?<tr>
? ? ? ?<td ALIGN="center"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>
? ? ?</tr>
? ? ? ?</table></td>
? ? ?</tr>
? ? ? ? ? ? ?<tr>
? ? ? ? ? ? ? ?<td COLSPAN="3" class="main" valign="top"><?php echo TEXT_BACKORDERS; ?></tr>
? ? ?<tr>
? ? ? ?<td ALIGN="center"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>
? ? ?</tr>
? ? <tr>
? ? ? ? ? ? ? <td class="main"><table border="0" width="100%" cellspacing="1" cellpadding="2">
? ?	<tr>
? ? ? <td width="10%" class="main" valign="top"><?php echo tep_draw_radio_field('backorders', 'Hold order until all items are in stock.', CHECKED) . '</td><td width="90%" class="main" valign="top">' . HOLD . '</td></tr><tr><td width="10%" class="main" valign="top">' . tep_draw_radio_field('backorders', 'Ship in-stock items now and backordered items as available. Additional shipping charges will apply.') . '</td><td width="90%" class="main" valign="top">' . SHIP . '</td></tr><tr><td width="10%" class="main" valign="top">' . tep_draw_radio_field('backorders', 'Ship in-stock items and cancel any backordered items.') . '</td><td width="90%" class="main" valign="top">' . CANCEL . '</td></tr></table>'; ?></td>
? ? ? ? ? ? </tr>
? ? ?<tr>
? ? ? ?<td ALIGN="center"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '25'); ?></td>
? ? ?</tr>

 

You can move the CHECKED text above to whichever option you want to have selected by default.

 

The part of this text marked in red:

 

"('backorders', 'Hold order until all items are in stock.', CHECKED) . '

 

is the text that will be stored in the 'backorders' field in the ORDERS_STATUS_HISTORY table, and carried forward onto the checkout_confirmation.php page and into the Email. Change it to read what you want.

 

In /catalog/includes/languages/english/checkout_shipping.php, add some defines (I put mine on the line right above the final '?>' at the bottom of the page):

 

define('HEADING_BACKORDERS', 'BACKORDERS');
define('TEXT_BACKORDERS', 'If any of the products you have ordered are listed as being on backorder, or become unavailable prior to your order being processed, please tell us how you would prefer to have your order handled:');

 

In /catalog/includes/languages/english.php, define the text for your radio buttons. Look for:

 

// text for gender
define('MALE', 'Male');
define('FEMALE', 'Female');
define('MALE_ADDRESS', 'Mr.');
define('FEMALE_ADDRESS', 'Ms.');

 

Right underneath it, add:

 

// text for backorders
define('HOLD', 'Hold order until all items are in stock.');
define('SHIP', 'Ship in-stock items now and backordered items (if any) as available. <b>(Additional shipping charges, based on package weight as outlined in our Shipping section, will apply to each shipment.)</b>');
define('CANCEL', 'Ship in-stock items and cancel any backordered item(s).');

 

In /catalog/includes/checkout_process.php, look for:

 

 ?$customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
?$sql_data_array = array('orders_id' => $insert_id,
? ? ? ? ? ? ? ? ? ? ? ? ?'orders_status_id' => $order->info['order_status'],
? ? ? ? ? ? ? ? ? ? ? ? ?'date_added' => 'now()',
? ? ? ? ? ? ? ? ? ? ? ? ?'customer_notified' => $customer_notification,
? ? ? ? ? ? ? ? ? ? ? ? ?'comments' => $order->info['comments']);
?tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

and replace with:

 

 ?$customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
?$sql_data_array = array('orders_id' => $insert_id,
? ? ? ? ? ? ? ? ? ? ? ? ?'orders_status_id' => $order->info['order_status'],
? ? ? ? ? ? ? ? ? ? ? ? ?'date_added' => 'now()',
? ? ? ? ? ? ? ? ? ? ? ? ?'customer_notified' => $customer_notification,
? ? ? ? ? ? ? ? ? ? ? ? ?'comments' => $order->info['comments'],
? ? ? ? ? ? ? ? ? ? ? ? ?'backorders' => $order->info['backorders']);
?tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

Then look for:

 

// lets start with the email confirmation
?$email_order = STORE_NAME . "\n" .
? ? ? ? ? ? ? ? EMAIL_SEPARATOR . "\n" .
? ? ? ? ? ? ? ? EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
? ? ? ? ? ? ? ? EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .
? ? ? ? ? ? ? ? EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
?if ($order->info['comments']) {
? ?$email_order .= tep_db_output($order->info['comments']) . "\n\n";
?}
?$email_order .= EMAIL_TEXT_PRODUCTS . "\n" .
? ? ? ? ? ? ? ? ?EMAIL_SEPARATOR . "\n" .
? ? ? ? ? ? ? ? ?$products_ordered .
? ? ? ? ? ? ? ? ?EMAIL_SEPARATOR . "\n";

 

and replace with:

 

// lets start with the email confirmation
?$email_order = STORE_NAME . "\n" .
? ? ? ? ? ? ? ? EMAIL_SEPARATOR . "\n" .
? ? ? ? ? ? ? ? EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
? ? ? ? ? ? ? ? EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .
? ? ? ? ? ? ? ? EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
?if ($order->info['comments']) {
? ?$email_order .= tep_db_output($order->info['comments']) . "\n\n";
?}
?$email_order .= EMAIL_SEPARATOR . "\n" .
? ? ?EMAIL_TEXT_BACKORDERS . "\n\n" .
tep_db_output($order->info['backorders']) . "\n\n";

?$email_order .= EMAIL_TEXT_PRODUCTS . "\n" .
? ? ? ? ? ? ? ? ?EMAIL_SEPARATOR . "\n" .
? ? ? ? ? ? ? ? ?$products_ordered .
? ? ? ? ? ? ? ? ?EMAIL_SEPARATOR . "\n";

 

Then look for:

 

// unregister session variables used during checkout
?tep_session_unregister('sendto');
?tep_session_unregister('billto');
?tep_session_unregister('shipping');
?tep_session_unregister('payment');
?tep_session_unregister('comments');

 

Replace with:

 

// unregister session variables used during checkout
?tep_session_unregister('sendto');
?tep_session_unregister('billto');
?tep_session_unregister('shipping');
?tep_session_unregister('payment');
?tep_session_unregister('comments');
?tep_session_unregister('backorders');

 

Next, in /catalog/includes/languages/english/checkout_process.php, look for:

 

define('EMAIL_TEXT_PRODUCTS', 'Products');

 

Right above it, add:

 

define('EMAIL_TEXT_BACKORDERS', 'You have selected to handle backordered items (if any) as follows:');

 

In /catalog/includes/checkout_confirmation.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']);
?}

 

Replace with:

 

 ?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']);

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

 

Then, right underneath the Shipping Method on that page, I remind them of the option they selected for handling backorders. Look for:

 

 ? ? ? ? ? ? ?<tr>
? ? ? ? ? ? ? ?<td class="main"><?php echo $order->info['shipping_method']; ?></td>
? ? ? ? ? ? ?</tr>

 

Replace with:

 

 ? ? ? ? ? ? ?<tr>
? ? ? ? ? ? ? ?<td class="main"><?php echo $order->info['shipping_method']; ?></td>
? ? ? ? ? ? ?</tr>
? ? ? ? ? ? ?<tr>
? ? ? ? ? ? ? ?<td class="main"><i><?php echo $order->info['backorders']; ?></i></td>
? ? ? ? ? ? ?</tr>

 

In /catalog/includes/classes/order.php, look for:

 

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

 

replace with:

 

 ? ? ? ? ? ? ? ? ? ? ? ? ?'tax_groups' => array(),
? ? ? ? ? ? ? ? ? ? ? ? ?'backorders' => (isset($GLOBALS['backorders']) ? $GLOBALS['backorders'] : ''),
? ? ? ? ? ? ? ? ? ? ? ? ?'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''));

 

Okay, I think that's it! Again, you'll need to carefully check your code (especially the HTML aspects) to see if it works for you, but you can see it in action by putting through a test order via my WWW link below.

 

HTH!

 

Terry

Link to comment
Share on other sites

  • 5 weeks later...

One Slight typo that should be mentioned:

 

where you say:

In /catalog/includes/checkout_confirmation.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']);
}

 

Replace with:

 

 

 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']);

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

 

The Replace with section should read:

 

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']);
}

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

Link to comment
Share on other sites

  • 1 year later...

I installed giftwrap but get this error after clicking continue in checkout_shipping

 

Fatal error: Cannot use object of type __PHP_Incomplete_Class as array in /home/crust/public_html/includes/classes/gift.php on line 25

 

Any ideas?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...