jeff2 Posted July 13, 2010 Share Posted July 13, 2010 I have used the add-on Request product Info which is fantastic. I have amended it slightly by adding the products model and manufacturer id this can be seen here; http://electricaldigest.co.uk/product/request-product-info.php?products_id=28 This is my first use of oscommerce and I am still finding my way around the app. What I need to do is add the extra fields products-model and manufacturer-id into email that is sent to the shop owner. As I do not know a great deal on the programming side, is there anyone who can propose a simple solution. In fact I would like to use the manufacturer-nam instead of the manufacturer-id but this is for me more complicated. Best regards jeff2 The amended code I have used is below; <?php /* $Id: request-product-info.php,v 1.0 by Jack_mcs @ support@oscommerce-solution.com osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_REQUEST_PRODUCT_INFO); function myunserialize($string) { $unserialized = stripslashes($string); $unserialized = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $unserialized ); return unserialize($unserialized); } $productList = array(); if (isset($HTTP_GET_VARS['productList'])) $productList = myunserialize($HTTP_GET_VARS['productList']); else if (isset($HTTP_GET_VARS['products_id'])) $productList[] = $HTTP_GET_VARS['products_id']; else if (isset($_POST['productList'])) $productList = myunserialize($_POST['productList']); if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) { $name = tep_db_prepare_input($HTTP_POST_VARS['name']); $email_address = tep_db_prepare_input($HTTP_POST_VARS['email']); $home = tep_db_prepare_input($HTTP_POST_VARS['home_address']); $comment = tep_db_prepare_input($HTTP_POST_VARS['comments']); $pID = tep_db_prepare_input($HTTP_POST_VARS['pID']); $error = false; if (! tep_not_null($name)) { $messageStack->add('request_info', ENTRY_NAME_ERROR); $error = true; } if (! tep_not_null($home)) { $messageStack->add('request_info', ENTRY_HOME_ERROR); $error = true; } if (! tep_validate_email($email_address)) { $messageStack->add('request_info', ENTRY_EMAIL_ADDRESS_CHECK_ERROR); $error = true; } if ($error == false) { $products = TEXT_PRODUCT_COLUMNS; for ($i = 0; $i < count($productList); ++$i) { $product_info_query = tep_db_query("select p.products_id, manufacturers_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$productList[$i] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); $products .= $product_info['products_id'] . "\t" . $product_info['products_name'] . "\n"; } $msg = sprintf(EMAIL_MESSAGE, $name, $products, $name, $email_address, $home, $comment); tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $msg, $name, $email_address); tep_redirect(tep_href_link(FILENAME_REQUEST_PRODUCT_INFO, 'action=success')); } } $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_REQUEST_PRODUCT_INFO)); ?> <!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"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><?php echo tep_draw_form('request_info', tep_href_link(FILENAME_REQUEST_PRODUCT_INFO, 'action=send')); ?><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> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php if ($messageStack->size('request_info') > 0) { ?> <tr> <td><?php echo $messageStack->output('request_info'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } else { if (tep_session_is_registered('customer_id')) { $account_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address, customers_telephone, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); $account = tep_db_fetch_array($account_query); $name = $account['customers_firstname'] . ' ' . $account['customers_lastname']; $email = $account['customers_email_address']; $phone = $account['customers_telephone']; $addressid = $account['customers_default_address_id']; $account_query = tep_db_query("select entry_street_address, entry_postcode , entry_city from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $customer_id . "' AND address_book_id = '" . (int)$addressid . "' "); $account = tep_db_fetch_array($account_query); $addressline1 = $account['entry_street_address']; $addressline2 = $account['entry_postcode']; $addressline3 = $account['entry_city']; $address = $name . "\n" . $account['entry_street_address'] . "\n" . $account['entry_postcode'] . ' ' . $account['entry_city'] ; } } if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) { ?> <tr> <td class="main" align="center"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_man_on_board.gif', HEADING_TITLE, '0', '0', 'align="left"') . TEXT_SUCCESS; ?></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 align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } else { ?> <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 class="main"><?php echo ENTRY_NAME; ?></td> </tr> <tr> <td class="main"><?php echo tep_draw_input_field('name', $name); ?></td> </tr> <tr> <td class="main"><?php echo ENTRY_EMAIL; ?></td> </tr> <tr> <td class="main"><?php echo tep_draw_input_field('email', $email); ?></td> </tr> <tr> <td class="main"><?php echo ENTRY_HOME_ADDRESS; ?></td> </tr> <tr> <td><table border="1" width="40%"> <tr> <td class="main"><?php echo tep_draw_textarea_field('home_address', 'soft', 2, 5, $address); ?></td> </tr> </table></td> </tr> <tr> <td class="main"><?php echo TEXT_PRODUCT_INFO; ?></td> </tr> <?php for ($i = 0; $i < count($productList); ++$i) { $product_info_query = tep_db_query("select p.products_id, manufacturers_id, p.products_model,pd.products_name, pd.products_description, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where p.products_status = '1' and p.products_id = '" . (int) $productList[$i] . "' and pd.language_id = '" . (int)$languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); if ($new_price = tep_get_products_special_price($product_info['products_id'])) { $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>'; } else { $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); } ?> <tr> <td><table border="1" cellpadding="0" width="100%"> <tr> <td class="main" width="15%" style="font-weight: bold;" valign="top"><?php echo TEXT_PRODUCT_NAME; ?></td> <td class="main"><?php echo $product_info['products_name']; ?></td> </tr> <tr> <td class="main" style="font-weight: bold;" valign="top"><?php echo TEXT_MANUFACTURER_ID; ?></td> <td class="main"><?php echo $product_info['manufacturers_id']; ?></td> </tr> <tr> <td class="main" style="font-weight: bold;" valign="top"><?php echo TEXT_PRODUCT_MODEL; ?></td> <td class="main"><?php echo $product_info['products_model']; ?></td> </tr> <tr> <td class="main" style="font-weight: bold;" valign="top"><?php echo TEXT_PRODUCT_DESC; ?></td> <td class="main"><?php echo $product_info['products_description']; ?></td> </tr> </table></td> </tr> <tr><td height="10"></td></tr> <?php } ?> <tr> <td class="main"><?php echo ENTRY_COMMENTS; ?></td> </tr> <tr> <td><table border="1" width="100%"> <tr> <td><?php echo tep_draw_textarea_field('comments', 'soft', 200, 10); ?></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') . tep_draw_hidden_field('productList', serialize($productList)); ?> </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> <?php } ?> </table></form></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- 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'); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.