Guest Posted May 2, 2005 Posted May 2, 2005 Okay, I spent a few days last week pounding this board to find a solution for those of us who send products via email. I, like a few of you do not want the Delivery Address on the check out pages to display the persons real mailing address because we Email them our products. So, this is what I created. It is only a hack. I am not sure if anyone else will find this usefull but perhaps, this could be a contribution. If you like it, maybe this could be my first contribution. :thumbsup: Anyhow, I have been asking a lot of questions on the board and I just wanted to give back a little. Features. 1. It changes the Delivery Address to the customers Email address. So, once this is added, the Shipping address could say, "Your items are set to be delivered to you via email. For security purposes the delivery email address is defaulted to the addresss used during the login." 2. The arrow pointing to the Delivery Address now points to the person's Email Address. The Arrow text now says "E-Mail Delivery Address:" 3. The Delivery Address is the persons Email Address. 4. When you click on "Change Address", it now takes the person to a page where they can change their Email Address, not their personal address. 5. The Change Address Page says "The new email address you enter will be used as your new login ID. All email communication will be sent to this address as soon as it is changed." 6. When clicking on "back" on the Change Address page, it will take them back to the checkout page. 7. When clicking on "continue" on the Change Address page, it will change the persons Email Address, redisplay this address in the persons check out page. 8. There is a topic where someone asked " where can I edit the text of sent mail, where can I edit the text of sent mail" http://www.oscommerce.com/forums/index.php?showtopic=117208&hl= I added a solution towards the bottom for this, so when you recieve the email from the system alerting you of a new order, the customers email address is there. For answers on how to do that, my hack is there. SOLUTION ___________ 1. Back up your files... I am really a newbe at this (born a few weeks ago), this is just something I did last week and it works for me. I take no responsibility for your problems. I am very new with PHP (I can hack around the code and read HTML, but I can not write PHP) and I have only been playing with OSCOMMERCE for a few weeks, so try this out on a test site... 2. Back up your files.. !!!!!!!!!!!!!!! 3. The page we want to edit is the catalog/checkout_shipping.php find <tr> <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> </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="50%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_DESTINATION . '<br><br><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td> <td align="right" width="50%" valign="top"> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td class="main" align="center" valign="top"><?php echo '<b>' . TITLE_SHIPPING_ADDRESS . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main" valign="top"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> Comment out all the the code listed above by "<!--" in the first <tr> of the first line of this code and a </tr> "-->" in the last line of this code Following the last commented out (Line 258 for me) I addeed this <!-- ADDED BY PURA VIDA TO GET THE EMAIL ADDRESS LISTED ON THE SHIPPING LABEL --> <?php $account_query = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); $account = tep_db_fetch_array($account_query); ?> <!-- This little bit of code is not used but I left it just incase you want to play around with the display of the email address, at least you know what code to edit. <?php //echo ENTRY_EMAIL_ADDRESS; ?> <?php //echo $account['customers_email_address']; ?> ---> <!-- NEW CODE FOR EMAIL ONLY SHIPPING --> <tr> <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_EMAIL_ADDRESS; ?></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="50%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_EMAIL_COMMENT . '<br><br><a href="' . tep_href_link(FILENAME_CHECKOUT_EMAIL_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td> <td align="right" width="50%" valign="top"> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td class="main" align="center" valign="top"><?php echo '<b>' . TITLE_SHIPPING_EMAIL_ADDRESS . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main" valign="middle"><br><br><?php echo $account['customers_email_address']; ?></td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <!-- END NEW CODE FOR EMAIL ONLY SHIPPING --> 4. Look at the /includes/languages/english/checkout_shipping.php Add this around line 22 define('TABLE_HEADING_SHIPPING_EMAIL_ADDRESS', 'Shipping Address'); define('TEXT_CHOOSE_SHIPPING_EMAIL_COMMENT', 'Your items are set to be delivered to you via email. For security purposes the delivery email address is defaulted to the addresss used during the login. '); define('TITLE_SHIPPING_EMAIL_ADDRESS', 'E-Mail Delivery Address:'); Please note, this last page you can change the text to say anything you want. If all goes well, this will change your page to display the EMAIL address. If your layout looks funky, then play around with where you put the code I have listed above as all templates are different. It took me a few hours to get the tables lined up and the text lined up. But the code above should do it. 5. If someone wants to change their email address, then let them. Since I do not know php, i let them change their address, but I do not know how to let them change their email address or add it to an address book. THIS WOULD MAKE A GREAT ADD ON TO THIS, SO IF ANYONE CAN HELP WITH THAT. IT WOULD BE GREAT TO ALLOW A CUSTOMER TO ADD MULTIPLE EMAIL ADDRESS FOR DELIVERY. Any how, this does the job. There is a notice, that once the person changes their email address, it will change their login ID as well. You have to create two new files, First File, I called it, "/catalog/checkout_email_address.php" Second File, I called it "/catalog/includes/languages/english/account_edit_email_address.php Okay, here is the code to put into the new /catalog/checkout_email_address.php <?php /* $Id: checkout_email_addres.php,v 1.65 2003/06/09 23:03:52 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } // needs to be included earlier to set the success message in the messageStack require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_EDIT_EMAIL_ADDRESS); if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) { $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']); $error = false; if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) { $error = true; $messageStack->add('checkout_email_address', ENTRY_EMAIL_ADDRESS_ERROR); } if (!tep_validate_email($email_address)) { $error = true; $messageStack->add('checkout_email_address', ENTRY_EMAIL_ADDRESS_CHECK_ERROR); } $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' and customers_id != '" . (int)$customer_id . "'"); $check_email = tep_db_fetch_array($check_email_query); if ($check_email['total'] > 0) { $error = true; $messageStack->add('checkout_email_address', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS); } if ($error == false) { $sql_data_array = array('customers_email_address' => $email_address); tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'"); tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customer_id . "'"); $sql_data_array = array('entry_firstname' => $firstname, 'entry_lastname' => $lastname); tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$customer_default_address_id . "'"); // reset the session variables $customer_first_name = $firstname; $messageStack->add_session('checkout_shipping', SUCCESS_ACCOUNT_UPDATED, 'success'); tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } } $account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_telephone, customers_fax from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); $account = tep_db_fetch_array($account_query); $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_EMAIL_ADDRESS, '', 'SSL')); $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_EDIT_EMAIL_ADDRESS, '', 'SSL')); ?> <!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"> <?php require('includes/form_check.js.php'); ?> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="0" cellpadding="0" class="maincont_tb"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top" class="maincont_left_td"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0" class="leftbar_tb"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top" class="maincont_mid_td"><?php echo tep_draw_form('checkout_email_address', tep_href_link(FILENAME_CHECKOUT_EMAIL_ADDRESS, '', 'SSL'), 'post', 'onSubmit="return check_form(checkout_email_address);"') . tep_draw_hidden_field('action', 'process'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php if ($messageStack->size('checkout_email_address') > 0) { ?> <tr> <td><?php echo $messageStack->output('checkout_email_address'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } ?> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main"><b><?php echo MY_ACCOUNT_TITLE; ?></b></td> <td class="inputRequirement" align="right"><?php echo FORM_REQUIRED_INFORMATION; ?></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" cellspacing="2" cellpadding="2"> <tr> <td class="main"><?php echo ENTRY_EMAIL_ADDRESS; ?></td> <td class="main"><?php echo tep_draw_input_field('email_address', $account['customers_email_address']) . ' ' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''); ?></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></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 width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td> <td align="right" class="main"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> </table></form></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top" class="maincont_right_td"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0" class="rightbar_tb"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Next, here is the code to put into /catalog/includes/languages/english/account_edit_email_address.php [/code] <?php /* $Id: account_edit.php,v 1.8 2003/05/19 20:17:50 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ define('NAVBAR_TITLE_1', 'My Email Address'); define('NAVBAR_TITLE_2', 'Edit Email Address'); define('HEADING_TITLE', 'Edit Email Address<br><br><font color="#FF0000">The new email address you enter will be used as your new login ID. All email communication will be sent to this address as soon as it is changed.</font>'); define('MY_ACCOUNT_TITLE', 'My Email Address'); define('SUCCESS_ACCOUNT_UPDATED', 'Your Email Address has been successfully updated.'); ?> 6. You have to add those files to the filnenames.php in the /catalog/includes define('FILENAME_CHECKOUT_EMAIL_ADDRESS', 'checkout_email_address.php'); define('FILENAME_ACCOUNT_EDIT_EMAIL_ADDRESS', 'account_edit_email_address.php'); I assume your formatting will be different, but this works for me. Please remember, I am really a newbe so if I missed any steps, let me know and I will do my best to see if there was more done to my site that I forgot to mention here. Any feed back is welcome Pura Vida
Recommended Posts
Archived
This topic is now archived and is closed to further replies.