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









