Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

arkisaeo

Pioneers
  • Posts

    65
  • Joined

  • Last visited

Profile Information

  • Real Name
    mituka aufaey

arkisaeo's Achievements

  1. I am getting this error when I try to delete existing option names or option values: Warning: Cannot modify header information - headers already sent by (output started at *******/admin/products_attributes.php:18) in *******/admin/includes/functions/general.php on line 34 This is line 18 in products_attributes: <script type="text/javascript"> (it is part of the code from your mod that goes like ?> <script type="text/javascript"> function createRequest() { return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); } etc...) This is line 34 in general.php: header('Location: ' . $url); Neither file has a blank space or line at the beginning or end of the file The options do delete, but I still get that error nonetheless.
  2. Having some issues with installing this. A couple of the files are already modded (though I can't remember which contribs I added to them), and some content is missing, so I'm not sure where to add the code. Here's where the issues lie: ^^^ That section in red is missing from the products_new.php file. And I'm not sure where to add the new code below it...(or if I even can) Here's the actual code I do have for that file::: <?php /* $Id: products_new.php v2.8 2009-12-31 00:52:16Z hpdl $ modified for thumbnail view 2007-07-24 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'); unset($_GET['manufacturers_id']); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCTS_NEW); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCTS_NEW)); ?> <!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 include (DIR_WS_INCLUDES . 'page-header-inc.htc'); ?> </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"><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"></td> </tr> </table></td> </tr> <?php $products_new_array = array(); $max_age = tep_not_null( MAX_DISPLAY_PRODUCTS_NEW_AGE ) ? MAX_DISPLAY_PRODUCTS_NEW_AGE : 60; // set max age of displayed product $date = strtotime("-" . $max_age . " days"); $date = strftime("%Y-%m-%d",$date); $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW); asort($define_list); $column_list = array(); reset($define_list); while (list($key, $value) = each($define_list)) { if ($value > 0) $column_list[] = $key; } $select_column_list = ''; for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_NAME': $select_column_list .= 'pd.products_name, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } } $sort_sql=''; if ( (!isset($_GET['sort'])) || (!ereg('^[1-8][ad]$', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) { $_GET['sort'] = 0 . 'd'; $sort_sql = " order by p.products_date_added DESC, pd.products_name"; } else { $sort_col = substr($_GET['sort'], 0 , 1); $sort_order = substr($_GET['sort'], 1); switch ($column_list[$sort_col-1]) { case 'PRODUCT_LIST_MODEL': $sort_sql .= " order by p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_NAME': $sort_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : ''); break; case 'PRODUCT_LIST_MANUFACTURER': $sort_sql .= " order by m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_QUANTITY': $sort_sql .= " order by p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_IMAGE': $sort_sql .= " order by pd.products_name"; break; case 'PRODUCT_LIST_WEIGHT': $sort_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_PRICE': $sort_sql .= " order by p.products_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; } } $products_new_query_raw = "select " . $select_column_list . "p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.manufacturers_id from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_date_added > '".$date."' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'" . $sort_sql; $listing_sql = $products_new_query_raw; $new_page = true; ?> <tr> <td><?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td> </tr> </table></td> <!-- body_text_eof //--> </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'); ?> And here's the other issue: ^^^ Again, the code in red is also missing from new_products.php. And I'm not sure where to add the new code below it (or if it's even possible...) Here is the actual code I have for that file::: <?php /* $Id: new_products.php v2.8 2009-12-31 22:48:15Z hpdl $ modified for thumbnail view 2007-07-24 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2008 osCommerce Released under the GNU General Public License */ ?> <!-- new_products //--> <?php $max_age = tep_not_null( MAX_DISPLAY_PRODUCTS_NEW_AGE ) ? MAX_DISPLAY_PRODUCTS_NEW_AGE : 60; // set max age of displayed product $date = strtotime("-" . $max_age . " days"); $date = strftime("%Y-%m-%d",$date); $new_mode = sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')); $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW); asort($define_list); $column_list = array(); reset($define_list); while (list($key, $value) = each($define_list)) { if ($value > 0) $column_list[] = $key; } $select_column_list = ''; for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_NAME': $select_column_list .= 'pd.products_name, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } } $order = ' order by p.products_date_added desc'; // $order = ' order by rand()'; // uncomment if you want products in a random order if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { $new_products_query = "select " . $select_column_list . "p.products_id, p.products_image, p.products_tax_class_id, p.products_price, p.products_quantity from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_date_added > '".$date."' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'" . $order; } else { $new_products_query = "select distinct " . $select_column_list . "p.products_id, p.products_image, p.products_tax_class_id, p.products_price, p.products_quantity from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_date_added > '".$date."' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'" . $order; } $listing_sql = $new_products_query; include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?> <!-- new_products_eof //-->
  3. Ok, I needed to add something to my site that would allow multiple images to be used. This particular add-on did the trick. For the most part, it works nicely. However, there is one big issue: Whenever used, the attributes/options for a product disappear. To explain further: All of my products need to be priced via attributes. They all come in multiple sizes, and so require multiple prices/options to be available. This has worked fine so far. If I have a product with just one image, the price options are still displayed on the page. However, if a product has multiple images, the price options disappear. I'd like to have the product pages display both the multiple images and the price options. There are only 2 main files edited for this add-on: admin/categories.php and catalog/product_info.php. My bet is the issue is in the product_info.php, but I'm not sure where. I have other add-ons installed and have rearranged some code on there previously (to rearrange stuff on the page), but below is the product_info code. (I should probably also add that this add-on is commented as "Simple multi image addon".) <?php /* $Id: product_info.php 1739 2007-12-20 00:52:16Z hpdl $ 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'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO); /* $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_check = tep_db_fetch_array($product_check_query); */ // Simple multi image addon $image_group = TINY_IMAGE_GROUP_SIZE; //Number of images to show per row/column $vertical_format = (ADDITIONAL_IMAGE_FORMAT == 'vertical'); $max_title_length = 40; //Set the maximm length of popup titles before they are broken into multiple lines. $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, p.products_image_array, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); $products_image_array = unserialize($product_info['products_image_array']); if (!is_array($products_image_array)) $products_image_array = array(); // EOF Simple multi image addon ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <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"> <script language="javascript"><!-- function popupWindow(url) { window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150') } //--></script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-17711155-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <!-- Simple multi image addon --> <script type="text/javascript" src="<?php echo DIR_WS_IMAGES ?>js/jquery.js"></script> <script type="text/javascript" src="<?php echo DIR_WS_IMAGES ?>js/jquery.fancybox.js"></script> <script type="text/javascript" src="<?php echo DIR_WS_IMAGES ?>js/jquery.easing.js"></script> <script type="text/javascript" src="<?php echo DIR_WS_IMAGES ?>js/jquery.easydrag.handler.beta2.js"></script> <link rel="stylesheet" href="<?php echo DIR_WS_IMAGES ?>js/fancybox.css" type="text/css" media="screen"> <script type="text/javascript"> $(document).ready(function() { $("div#fancy a").fancybox({ 'zoomSpeedIn': 800, 'zoomSpeedOut': 700, 'imageScale' : true, 'centerOnScroll': true, 'hideOnContentClick' : false, 'overlayShow': <?php echo (DIM_BACKGROUND == 'true' ? 'true' : 'false'); ?>, 'overlayOpacity': <?php echo (BKG_LUMA/10); ?>, 'zoomOpacity': true, <?php if (SWING_POPUP == 'true') echo "'easingIn' : 'easeOutBack',"; ?> 'hideOnContentClick': false }); <?php if (DRAG_POPUP == 'true') echo '$("#fancy_outer").easydrag();'; ?> }); </script> <style type="text/css"> <?php if (SHOW_NAV == 'true') echo 'span#fancy_left_ico {left: 20px;} span#fancy_right_ico {right: 20px;}'; switch (POS_NAV) { case 'top': echo 'span.fancy_ico { top: 38px; }'; break; case 'bottom': echo 'span.fancy_ico { bottom: 20px; }'; break; default: echo 'span.fancy_ico { top: 50%; }'; break; } ?> </style> <!-- EOF Simple multi image addon --> </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('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> <?php /* if ($product_check['total'] < 1) { */ // Simple multi image addon if (!tep_db_num_rows($product_info_query)) { // EOF Simple multi image addon ?> <tr> <td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td> </tr> <tr> <td class="main"><table border="0" width="100%" cellspacing="1" cellpadding="2"> <tr> <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('continue.png', 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 { /* $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); */ // Simple multi image addon section moved tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); 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'])); } if (tep_not_null($product_info['products_model'])) { $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>'; } else { $products_name = $product_info['products_name']; } ?> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading" valign="top" colspan="2"><?php echo $products_name; ?></td> </tr> </table></td> </tr> <tr> <td class="main"> <?php if (tep_not_null($product_info['products_image'])) { ?> <!-- Simple multi image addon --> <div id="fancy"> <table border="0" cellspacing="0" cellpadding="2" align="right"> <tr> <td align="center" class="smallText"> <?php if (strlen($product_info['products_name']) > $max_title_length) { $title = wordwrap(htmlspecialchars($product_info['products_name']), $max_title_length, '<br>'); } else { $title = htmlspecialchars($product_info['products_name']); } $m_source = ''; $thumb = (class_exists('oscthumb') && CFG_MASTER_SWITCH == 'On'); if ($thumb) { preg_match('/"([^"]+)"/',htmlentities ( tep_image(DIR_WS_IMAGES . $product_info['products_image'],'','','','','',5), ENT_NOQUOTES), $image); $m_source=str_replace('&','&',$image[1]); } echo '<a rel="image_group" title="'.$title.'" href="' . ($m_source ? $m_source : DIR_WS_IMAGES . $product_info['products_image']) . '" alt="' . $product_info['products_name'] . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"', false, 5) . '<br /></a>'; if(!$vertical_format) { echo ''; $row = 1; reset($products_image_array); foreach($products_image_array as $value) { if ($thumb) { $source = ''; preg_match('/"([^"]+)"/',htmlentities ( tep_image(DIR_WS_IMAGES . $value,'','','','','',5), ENT_NOQUOTES), $image); $source=str_replace('&','&',$image[1]); } echo '<a rel="image_group" title="'.$title.'" href="' . ($source ? $source : DIR_WS_IMAGES . $value) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $value, $product_info['products_name'], TINY_IMAGE_WIDTH, TINY_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '</a>'; ++$row; if ($row > $image_group) { echo '<br />'; $row = 1; } } } echo '</td>'; if($vertical_format) { echo '<td>'; $row = 1; reset($products_image_array); foreach($products_image_array as $value) { if ($thumb) { $source = ''; preg_match('/"([^"]+)"/',htmlentities ( tep_image(DIR_WS_IMAGES . $value,'','','','','',5), ENT_NOQUOTES), $image); $source=str_replace('&','&',$image[1]); } echo '<a rel="image_group" title="'.$title.'" href="' . ($source ? $source : DIR_WS_IMAGES . $value) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $value, $product_info['products_name'], TINY_IMAGE_WIDTH, TINY_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br />' . '</a>'; ++$row; if ($row > $image_group) { echo '</td><td>'; $row = 1; } } echo '</td>'; } ?> </tr><?php echo '<tr><td class="smallText">' . TEXT_CLICK_TO_ENLARGE . '</td></tr>'; ?> </table> </div> <!-- EOF Simple multi image addon --> <?php } ?> <p><?php echo stripslashes($product_info['products_description']); ?></p> <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { ?> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td> </tr> <?php $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]; } else { $selected_attribute = false; } ?> <tr> <td class="main"><?php echo tep_draw_radio_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td> </tr> <?php } ?> </table> <?php } ?> </td> </tr> <?php $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); $reviews = tep_db_fetch_array($reviews_query); if ($reviews['count'] > 0) { ?> <tr> <td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?></td> </tr> <?php } if (tep_not_null($product_info['products_url'])) { ?> <tr> <td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false)); ?></td> </tr> <?php } if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) { ?> <tr> <td align="center" class="main"> <p class="smallText"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></p></td> </tr> <?php } else { ?> <?php } ?> <tr> <td class="main"><table border="0" width="100%" cellspacing="1" cellpadding="2"> <tr> <td class="main"><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 class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('reviews.png', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td> <td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('add_to_cart.png', IMAGE_BUTTON_IN_CART); ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td> <?php if ((USE_CACHE == 'true') && empty($SID)) { echo tep_cache_also_purchased(3600); } else { include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS); } } ?> </td> </tr> </table></form></td> <!-- body_text_eof //--> </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'); ?>
  4. Ok, I'm a bit confused about something with this add-on. It works fine, except...it doesn't do what I thought it would. I thought it would combine both master and slave products into one order.. like bundle them together as a package deal thing, but the slave product would be optional. For example: I have a master product (say, a shirt) for $10 and a slave product for $5 (a hat, for example). I thought it would be so the slave product (hat) was optional--you COULD buy it with the master product (shirt), but you don't HAVE to buy it. So, if someone wanted to buy one hat (slave product) with the shirt (master product), they'd input a quantity number (1) and hit the "buy now" or "add to cart" button. Then on the shopping cart it would show $15 ---$10 for the shirt (master product) + $5 for adding the hat (slave product). But there is one main problem: Whether you select a slave product or not, the only thing that shows up in the shopping cart is the slave product--the master product does not show up in the shopping cart at all. So, I'm wondering, are they even supposed to be included together in the sale? (should the master and slave both be listed in the shopping cart?) Or is that just not an option and does it work completely different? And how can it be set up so the slave product is optional and if it's not selected, then you'd just be purchasing the master product?
  5. Update again (sorry for the extra posts, unable to edit previous ones) First problem is fixed.. apparently the <?php code was missing from the very first line of the general.php file. All is good..for now!
  6. Update: Second problem was fixed (just had to edit/delete/rearrange some of the code). First problem still needs fixed.
  7. Ok, I just tried to install this and now I am having some major problems. First problem: When I go to the admin panel (ex. site.com/catalog/admin/index.php), this massive series of code and errors shows up: /* $Id: general.php 1739 2007-12-20 00:52:16Z hpdl $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2007 osCommerce Released under the GNU General Public License */ //// // Redirect to another page or site function tep_redirect($url) { global $logger; if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) { tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false)); } header('Location: ' . $url); if (STORE_PAGE_PARSE_TIME == 'true') { if (!is_object($logger)) $logger = new logger; $logger->timer_stop(); } exit; } //// // Parse the data used in the html tags to ensure the tags will not break function tep_parse_input_field_data($data, $parse) { return strtr(trim($data), $parse); } function tep_output_string($string, $translate = false, $protected = false) { if ($protected == true) { return htmlspecialchars($string); } else { if ($translate == false) { return tep_parse_input_field_data($string, array('"' => '"')); } else { return tep_parse_input_field_data($string, $translate); } } } function tep_output_string_protected($string) { return tep_output_string($string, false, true); } function tep_sanitize_string($string) { $string = ereg_replace(' +', ' ', $string); return preg_replace("/[<>]/", '_', $string); } function tep_customers_name($customers_id) { $customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'"); $customers_values = tep_db_fetch_array($customers); return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname']; } function tep_get_path($current_category_id = '') { global $cPath_array; if ($current_category_id == '') { $cPath_new = implode('_', $cPath_array); } else { if (sizeof($cPath_array) == 0) { $cPath_new = $current_category_id; } else { $cPath_new = ''; $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'"); $last_category = tep_db_fetch_array($last_category_query); $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'"); $current_category = tep_db_fetch_array($current_category_query); if ($last_category['parent_id'] == $current_category['parent_id']) { for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) { $cPath_new .= '_' . $cPath_array[$i]; } } else { for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) { $cPath_new .= '_' . $cPath_array[$i]; } } $cPath_new .= '_' . $current_category_id; if (substr($cPath_new, 0, 1) == '_') { $cPath_new = substr($cPath_new, 1); } } } return 'cPath=' . $cPath_new; } function tep_get_all_get_params($exclude_array = '') { global $HTTP_GET_VARS; if ($exclude_array == '') $exclude_array = array(); $get_url = ''; reset($HTTP_GET_VARS); while (list($key, $value) = each($HTTP_GET_VARS)) { if (($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&'; } return $get_url; } function tep_date_long($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $year = (int)substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); return strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year)); } //// // Output a raw date string in the selected locale date format // $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS // NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers function tep_date_short($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $year = substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) { return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); } else { return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037))); } } function tep_datetime_short($raw_datetime) { if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false; $year = (int)substr($raw_datetime, 0, 4); $month = (int)substr($raw_datetime, 5, 2); $day = (int)substr($raw_datetime, 8, 2); $hour = (int)substr($raw_datetime, 11, 2); $minute = (int)substr($raw_datetime, 14, 2); $second = (int)substr($raw_datetime, 17, 2); return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); } function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) { global $languages_id; if (!is_array($category_tree_array)) $category_tree_array = array(); if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP); if ($include_itself) { $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'"); $category = tep_db_fetch_array($category_query); $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']); } $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']); $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . ' ', $exclude, $category_tree_array); } return $category_tree_array; } function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') { global $currencies, $languages_id; if ($exclude == '') { $exclude = array(); } $select_string = ''; return $select_string; } function tep_options_name($options_id) { global $languages_id; $options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'"); $options_values = tep_db_fetch_array($options); return $options_values['products_options_name']; } function tep_values_name($values_id) { global $languages_id; $values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$languages_id . "'"); $values_values = tep_db_fetch_array($values); return $values_values['products_options_values_name']; } function tep_info_image($image, $alt, $width = '', $height = '') { if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) { $image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height); } else { $image = TEXT_IMAGE_NONEXISTENT; } return $image; } function tep_break_string($string, $len, $break_char = '-') { $l = 0; $output = ''; for ($i=0, $n=strlen($string); $i<$n; $i++) { $char = substr($string, $i, 1); if ($char != ' ') { $l++; } else { $l = 0; } if ($l > $len) { $l = 1; $output .= $break_char; } $output .= $char; } return $output; } function tep_get_country_name($country_id) { $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'"); if (!tep_db_num_rows($country_query)) { return $country_id; } else { $country = tep_db_fetch_array($country_query); return $country['countries_name']; } } function tep_get_zone_name($country_id, $zone_id, $default_zone) { $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'"); if (tep_db_num_rows($zone_query)) { $zone = tep_db_fetch_array($zone_query); return $zone['zone_name']; } else { return $default_zone; } } function tep_not_null($value) { if (is_array($value)) { if (sizeof($value) > 0) { return true; } else { return false; } } else { if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) { return true; } else { return false; } } } function tep_browser_detect($component) { global $HTTP_USER_AGENT; return stristr($HTTP_USER_AGENT, $component); } function tep_tax_classes_pull_down($parameters, $selected = '') { $select_string = ''; return $select_string; } function tep_geo_zones_pull_down($parameters, $selected = '') { $select_string = ''; return $select_string; } function tep_get_geo_zone_name($geo_zone_id) { $zones_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$geo_zone_id . "'"); if (!tep_db_num_rows($zones_query)) { $geo_zone_name = $geo_zone_id; } else { $zones = tep_db_fetch_array($zones_query); $geo_zone_name = $zones['geo_zone_name']; } return $geo_zone_name; } function tep_address_format($address_format_id, $address, $html, $boln, $eoln) { $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'"); $address_format = tep_db_fetch_array($address_format_query); $company = tep_output_string_protected($address['company']); if (isset($address['firstname']) && tep_not_null($address['firstname'])) { $firstname = tep_output_string_protected($address['firstname']); $lastname = tep_output_string_protected($address['lastname']); } elseif (isset($address['name']) && tep_not_null($address['name'])) { $firstname = tep_output_string_protected($address['name']); $lastname = ''; } else { $firstname = ''; $lastname = ''; } $street = tep_output_string_protected($address['street_address']); $suburb = tep_output_string_protected($address['suburb']); $city = tep_output_string_protected($address['city']); $state = tep_output_string_protected($address['state']); if (isset($address['country_id']) && tep_not_null($address['country_id'])) { $country = tep_get_country_name($address['country_id']); if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) { $state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state); } } elseif (isset($address['country']) && tep_not_null($address['country'])) { $country = tep_output_string_protected($address['country']); } else { $country = ''; } $postcode = tep_output_string_protected($address['postcode']); $zip = $postcode; if ($html) { // HTML Mode $HR = ''; $hr = ''; if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults $CR = ' '; $cr = ' '; $eoln = $cr; } else { // Use values supplied $CR = $eoln . $boln; $cr = $CR; } } else { // Text Mode $CR = $eoln; $cr = $CR; $HR = '----------------------------------------'; $hr = '----------------------------------------'; } $statecomma = ''; $streets = $street; if ($suburb != '') $streets = $street . $cr . $suburb; if ($country == '') $country = tep_output_string_protected($address['country']); if ($state != '') $statecomma = $state . ', '; $fmt = $address_format['format']; eval("\$address = \"$fmt\";"); if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) { $address = $company . $cr . $address; } return $address; } //////////////////////////////////////////////////////////////////////////////////////////////// // // Function : tep_get_zone_code // // Arguments : country country code string // zone state/province zone_id // def_state default string if zone==0 // // Return : state_prov_code state/province code // // Description : Function to retrieve the state/province code (as in FL for Florida etc) // //////////////////////////////////////////////////////////////////////////////////////////////// function tep_get_zone_code($country, $zone, $def_state) { $state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'"); if (!tep_db_num_rows($state_prov_query)) { $state_prov_code = $def_state; } else { $state_prov_values = tep_db_fetch_array($state_prov_query); $state_prov_code = $state_prov_values['zone_code']; } return $state_prov_code; } function tep_get_uprid($prid, $params) { $uprid = $prid; if ( (is_array($params)) && (!strstr($prid, '{')) ) { while (list($option, $value) = each($params)) { $uprid = $uprid . '{' . $option . '}' . $value; } } return $uprid; } function tep_get_prid($uprid) { $pieces = explode('{', $uprid); return $pieces[0]; } function tep_get_languages() { $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); while ($languages = tep_db_fetch_array($languages_query)) { $languages_array[] = array('id' => $languages['languages_id'], 'name' => $languages['name'], 'code' => $languages['code'], 'image' => $languages['image'], 'directory' => $languages['directory']); } return $languages_array; } function tep_get_category_name($category_id, $language_id) { $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'"); $category = tep_db_fetch_array($category_query); return $category['categories_name']; } function tep_get_orders_status_name($orders_status_id, $language_id = '') { global $languages_id; if (!$language_id) $language_id = $languages_id; $orders_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$orders_status_id . "' and language_id = '" . (int)$language_id . "'"); $orders_status = tep_db_fetch_array($orders_status_query); return $orders_status['orders_status_name']; } function tep_get_orders_status() { global $languages_id; $orders_status_array = array(); $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_id"); while ($orders_status = tep_db_fetch_array($orders_status_query)) { $orders_status_array[] = array('id' => $orders_status['orders_status_id'], 'text' => $orders_status['orders_status_name']); } return $orders_status_array; } function tep_get_products_name($product_id, $language_id = 0) { global $languages_id; if ($language_id == 0) $language_id = $languages_id; $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'"); $product = tep_db_fetch_array($product_query); return $product['products_name']; } // Master Products function tep_get_products_master_status($product_id) { $product_query = tep_db_query("select products_master_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'"); $product = tep_db_fetch_array($product_query); return $product['products_master_status']; } // Master Products EOF function tep_get_products_description($product_id, $language_id) { $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'"); $product = tep_db_fetch_array($product_query); return $product['products_description']; } function tep_get_products_url($product_id, $language_id) { $product_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'"); $product = tep_db_fetch_array($product_query); return $product['products_url']; } //// // Return the manufacturers URL in the needed language // TABLES: manufacturers_info function tep_get_manufacturer_url($manufacturer_id, $language_id) { $manufacturer_query = tep_db_query("select manufacturers_url from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'"); $manufacturer = tep_db_fetch_array($manufacturer_query); return $manufacturer['manufacturers_url']; } //// // Wrapper for class_exists() function // This function is not available in all PHP versions so we test it before using it. function tep_class_exists($class_name) { if (function_exists('class_exists')) { return class_exists($class_name); } else { return true; } } //// // Count how many products exist in a category // TABLES: products, products_to_categories, categories function tep_products_in_category_count($categories_id, $include_deactivated = false) { $products_count = 0; if ($include_deactivated) { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$categories_id . "'"); } else { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$categories_id . "'"); } $products = tep_db_fetch_array($products_query); $products_count += $products['total']; $childs_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'"); if (tep_db_num_rows($childs_query)) { while ($childs = tep_db_fetch_array($childs_query)) { $products_count += tep_products_in_category_count($childs['categories_id'], $include_deactivated); } } return $products_count; } //// // Count how many subcategories exist in a category // TABLES: categories function tep_childs_in_category_count($categories_id) { $categories_count = 0; $categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'"); while ($categories = tep_db_fetch_array($categories_query)) { $categories_count++; $categories_count += tep_childs_in_category_count($categories['categories_id']); } return $categories_count; } //// // Returns an array with countries // TABLES: countries function tep_get_countries($default = '') { $countries_array = array(); if ($default) { $countries_array[] = array('id' => '', 'text' => $default); } //-MS- Added active countries $countries_query = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " where countries_status='1' order by countries_name"); //-MS- Added active countries EOM while ($countries = tep_db_fetch_array($countries_query)) { $countries_array[] = array('id' => $countries['countries_id'], 'text' => $countries['countries_name']); } return $countries_array; } //// // return an array with country zones function tep_get_country_zones($country_id) { $zones_array = array(); //-MS- Added Active-Zones support $zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_status='1' and zone_country_id = '" . (int)$country_id . "' order by zone_name"); //-MS- Added Active-Zones support EOM while ($zones = tep_db_fetch_array($zones_query)) { $zones_array[] = array('id' => $zones['zone_id'], 'text' => $zones['zone_name']); } return $zones_array; } function tep_prepare_country_zones_pull_down($country_id = '') { // preset the width of the drop-down for Netscape $pre = ''; if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) { for ($i=0; $i<45; $i++) $pre .= ' '; } $zones = tep_get_country_zones($country_id); if (sizeof($zones) > 0) { $zones_select = array(array('id' => '', 'text' => PLEASE_SELECT)); $zones = array_merge($zones_select, $zones); } else { $zones = array(array('id' => '', 'text' => TYPE_BELOW)); // create dummy options for Netscape to preset the height of the drop-down if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) { for ($i=0; $i<9; $i++) { $zones[] = array('id' => '', 'text' => $pre); } } } return $zones; } //// // Get list of address_format_id's function tep_get_address_formats() { $address_format_query = tep_db_query("select address_format_id from " . TABLE_ADDRESS_FORMAT . " order by address_format_id"); $address_format_array = array(); while ($address_format_values = tep_db_fetch_array($address_format_query)) { $address_format_array[] = array('id' => $address_format_values['address_format_id'], 'text' => $address_format_values['address_format_id']); } return $address_format_array; } //// // Alias function for Store configuration values in the Administration Tool function tep_cfg_pull_down_country_list($country_id) { return tep_draw_pull_down_menu('configuration_value', tep_get_countries(), $country_id); } function tep_cfg_pull_down_zone_list($zone_id) { return tep_draw_pull_down_menu('configuration_value', tep_get_country_zones(STORE_COUNTRY), $zone_id); } function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') { $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value'); $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title"); while ($tax_class = tep_db_fetch_array($tax_class_query)) { $tax_class_array[] = array('id' => $tax_class['tax_class_id'], 'text' => $tax_class['tax_class_title']); } return tep_draw_pull_down_menu($name, $tax_class_array, $tax_class_id); } //// // Function to read in text area in admin function tep_cfg_textarea($text) { return tep_draw_textarea_field('configuration_value', false, 35, 5, $text); } function tep_cfg_get_zone_name($zone_id) { $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'"); if (!tep_db_num_rows($zone_query)) { return $zone_id; } else { $zone = tep_db_fetch_array($zone_query); return $zone['zone_name']; } } //// // Sets the status of a banner function tep_set_banner_status($banners_id, $status) { if ($status == '1') { return tep_db_query("update " . TABLE_BANNERS . " set status = '1', expires_impressions = NULL, expires_date = NULL, date_status_change = NULL where banners_id = '" . $banners_id . "'"); } elseif ($status == '0') { return tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_status_change = now() where banners_id = '" . $banners_id . "'"); } else { return -1; } } //// // Sets the status of a product function tep_set_product_status($products_id, $status) { if ($status == '1') { return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1', products_last_modified = now() where products_id = '" . (int)$products_id . "'"); } elseif ($status == '0') { return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0', products_last_modified = now() where products_id = '" . (int)$products_id . "'"); } else { return -1; } } //// // Sets the status of a category function tep_set_categories_status($categ_id, $status) { if ($status == '1') { return tep_db_query("update " . TABLE_CATEGORIES . " set status_categ = '1', last_modified = now() where categories_id = '" . (int)$categ_id . "'"); } elseif ($status == '0') { return tep_db_query("update " . TABLE_CATEGORIES . " set status_categ = '0', last_modified = now() where categories_id = '" . (int)$categ_id . "'"); } else { return -1; } } //// // Sets the status of a product on special function tep_set_specials_status($specials_id, $status) { if ($status == '1') { return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'"); } elseif ($status == '0') { return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'"); } else { return -1; } } //// // Sets timeout for the current script. // Cant be used in safe mode. function tep_set_time_limit($limit) { if (!get_cfg_var('safe_mode')) { set_time_limit($limit); } } //// // Alias function for Store configuration values in the Administration Tool function tep_cfg_select_option($select_array, $key_value, $key = '') { $string = ''; for ($i=0, $n=sizeof($select_array); $i<$n; $i++) { $name = ((tep_not_null($key)) ? 'configuration[' . $key . ']' : 'configuration_value'); $string .= ' tep_datetime_short(date('Y-m-d H:i:s')), 'system' => $system, 'kernel' => $kernel, 'host' => $host, 'ip' => gethostbyname($host), 'uptime' => @exec('uptime'), 'http_server' => $HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'php' => PHP_VERSION, 'zend' => (function_exists('zend_version') ? zend_version() : ''), 'db_server' => DB_SERVER, 'db_ip' => gethostbyname(DB_SERVER), 'db_version' => 'MySQL ' . (function_exists('mysql_get_server_info') ? mysql_get_server_info() : ''), 'db_date' => tep_datetime_short($db['datetime'])); } function tep_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) { global $languages_id; if (!is_array($categories_array)) $categories_array = array(); if ($from == 'product') { $categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$id . "'"); while ($categories = tep_db_fetch_array($categories_query)) { if ($categories['categories_id'] == '0') { $categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP); } else { $category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $category = tep_db_fetch_array($category_query); $categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']); if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index); $categories_array[$index] = array_reverse($categories_array[$index]); } $index++; } } elseif ($from == 'category') { $category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $category = tep_db_fetch_array($category_query); $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']); if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index); } return $categories_array; } function tep_output_generated_category_path($id, $from = 'category') { $calculated_category_path_string = ''; $calculated_category_path = tep_generate_category_path($id, $from); for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) { for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) { $calculated_category_path_string .= $calculated_category_path[$i][$j]['text'] . ' > '; } $calculated_category_path_string = substr($calculated_category_path_string, 0, -16) . ' '; } $calculated_category_path_string = substr($calculated_category_path_string, 0, -4); if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP; return $calculated_category_path_string; } function tep_get_generated_category_path_ids($id, $from = 'category') { $calculated_category_path_string = ''; $calculated_category_path = tep_generate_category_path($id, $from); for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) { for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) { $calculated_category_path_string .= $calculated_category_path[$i][$j]['id'] . '_'; } $calculated_category_path_string = substr($calculated_category_path_string, 0, -1) . ' '; } $calculated_category_path_string = substr($calculated_category_path_string, 0, -4); if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP; return $calculated_category_path_string; } function tep_remove_category($category_id) { $category_image_query = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); $category_image = tep_db_fetch_array($category_image_query); $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where categories_image = '" . tep_db_input($category_image['categories_image']) . "'"); $duplicate_image = tep_db_fetch_array($duplicate_image_query); if ($duplicate_image['total'] < 2) { if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['categories_image'])) { @unlink(DIR_FS_CATALOG_IMAGES . $category_image['categories_image']); } } tep_db_query("delete from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "'"); tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } } function tep_remove_product($product_id) { $product_image_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'"); $product_image = tep_db_fetch_array($product_image_query); $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " where products_image = '" . tep_db_input($product_image['products_image']) . "'"); $duplicate_image = tep_db_fetch_array($duplicate_image_query); if ($duplicate_image['total'] < 2) { if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image'])) { @unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']); } } tep_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "'"); tep_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'"); tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'"); tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "'"); tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$product_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . (int)$product_id . "' or products_id like '" . (int)$product_id . "{%'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . (int)$product_id . "' or products_id like '" . (int)$product_id . "{%'"); $product_reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'"); while ($product_reviews = tep_db_fetch_array($product_reviews_query)) { tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$product_reviews['reviews_id'] . "'"); } tep_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'"); if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } } function tep_remove_order($order_id, $restock = false) { if ($restock == 'on') { $order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); while ($order = tep_db_fetch_array($order_query)) { tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'"); } } tep_db_query("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "'"); tep_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$order_id . "'"); tep_db_query("delete from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "'"); } function tep_reset_cache_block($cache_block) { global $cache_blocks; for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) { if ($cache_blocks[$i]['code'] == $cache_block) { if ($cache_blocks[$i]['multiple']) { if ($dir = @opendir(DIR_FS_CACHE)) { while ($cache_file = readdir($dir)) { $cached_file = $cache_blocks[$i]['file']; $languages = tep_get_languages(); for ($j=0, $k=sizeof($languages); $j<$k; $j++) { $cached_file_unlink = ereg_replace('-language', '-' . $languages[$j]['directory'], $cached_file); if (ereg('^' . $cached_file_unlink, $cache_file)) { @unlink(DIR_FS_CACHE . $cache_file); } } } closedir($dir); } } else { $cached_file = $cache_blocks[$i]['file']; $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $cached_file = ereg_replace('-language', '-' . $languages[$i]['directory'], $cached_file); @unlink(DIR_FS_CACHE . $cached_file); } } break; } } } function tep_get_file_permissions($mode) { // determine type if ( ($mode & 0xC000) == 0xC000) { // unix domain socket $type = 's'; } elseif ( ($mode & 0x4000) == 0x4000) { // directory $type = 'd'; } elseif ( ($mode & 0xA000) == 0xA000) { // symbolic link $type = 'l'; } elseif ( ($mode & 0x8000) == 0x8000) { // regular file $type = '-'; } elseif ( ($mode & 0x6000) == 0x6000) { //bBlock special file $type = 'b'; } elseif ( ($mode & 0x2000) == 0x2000) { // character special file $type = 'c'; } elseif ( ($mode & 0x1000) == 0x1000) { // named pipe $type = 'p'; } else { // unknown $type = '?'; } // determine permissions $owner['read'] = ($mode & 00400) ? 'r' : '-'; $owner['write'] = ($mode & 00200) ? 'w' : '-'; $owner['execute'] = ($mode & 00100) ? 'x' : '-'; $group['read'] = ($mode & 00040) ? 'r' : '-'; $group['write'] = ($mode & 00020) ? 'w' : '-'; $group['execute'] = ($mode & 00010) ? 'x' : '-'; $world['read'] = ($mode & 00004) ? 'r' : '-'; $world['write'] = ($mode & 00002) ? 'w' : '-'; $world['execute'] = ($mode & 00001) ? 'x' : '-'; // adjust for SUID, SGID and sticky bit if ($mode & 0x800 ) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S'; if ($mode & 0x400 ) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S'; if ($mode & 0x200 ) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T'; return $type . $owner['read'] . $owner['write'] . $owner['execute'] . $group['read'] . $group['write'] . $group['execute'] . $world['read'] . $world['write'] . $world['execute']; } function tep_remove($source) { global $messageStack, $tep_remove_error; if (isset($tep_remove_error)) $tep_remove_error = false; if (is_dir($source)) { $dir = dir($source); while ($file = $dir->read()) { if ( ($file != '.') && ($file != '..') ) { if (is_writeable($source . '/' . $file)) { tep_remove($source . '/' . $file); } else { $messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source . '/' . $file), 'error'); $tep_remove_error = true; } } } $dir->close(); if (is_writeable($source)) { rmdir($source); } else { $messageStack->add(sprintf(ERROR_DIRECTORY_NOT_REMOVEABLE, $source), 'error'); $tep_remove_error = true; } } else { if (is_writeable($source)) { unlink($source); } else { $messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source), 'error'); $tep_remove_error = true; } } } //// // Output the tax percentage with optional padded decimals function tep_display_tax_value($value, $padding = TAX_DECIMAL_PLACES) { if (strpos($value, '.')) { $loop = true; while ($loop) { if (substr($value, -1) == '0') { $value = substr($value, 0, -1); } else { $loop = false; if (substr($value, -1) == '.') { $value = substr($value, 0, -1); } } } } if ($padding > 0) { if ($decimal_pos = strpos($value, '.')) { $decimals = strlen(substr($value, ($decimal_pos+1))); for ($i=$decimals; $i<$padding; $i++) { $value .= '0'; } } else { $value .= '.'; for ($i=0; $i<$padding; $i++) { $value .= '0'; } } } return $value; } function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) { if (SEND_EMAILS != 'true') return false; // Instantiate a new mail object $message = new email(array('X-Mailer: osCommerce')); // Build the text version $text = strip_tags($email_text); if (EMAIL_USE_HTML == 'true') { $message->add_html($email_text, $text); } else { $message->add_text($text); } // Send message $message->build_message(); $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject); } function tep_get_tax_class_title($tax_class_id) { if ($tax_class_id == '0') { return TEXT_NONE; } else { $classes_query = tep_db_query("select tax_class_title from " . TABLE_TAX_CLASS . " where tax_class_id = '" . (int)$tax_class_id . "'"); $classes = tep_db_fetch_array($classes_query); return $classes['tax_class_title']; } } function tep_banner_image_extension() { if (function_exists('imagetypes')) { if (imagetypes() & IMG_PNG) { return 'png'; } elseif (imagetypes() & IMG_JPG) { return 'jpg'; } elseif (imagetypes() & IMG_GIF) { return 'gif'; } } elseif (function_exists('imagecreatefrompng') && function_exists('imagepng')) { return 'png'; } elseif (function_exists('imagecreatefromjpeg') && function_exists('imagejpeg')) { return 'jpg'; } elseif (function_exists('imagecreatefromgif') && function_exists('imagegif')) { return 'gif'; } return false; } //// // Wrapper function for round() for php3 compatibility function tep_round($value, $precision) { if (PHP_VERSION < 4) { $exp = pow(10, $precision); return round($value * $exp) / $exp; } else { return round($value, $precision); } } //// // Add tax to a products price function tep_add_tax($price, $tax, $override = false) { if ( ( (DISPLAY_PRICE_WITH_TAX == 'true') || ($override == true) ) && ($tax > 0) ) { return $price + tep_calculate_tax($price, $tax); } else { return $price; } } // Calculates Tax rounding the result function tep_calculate_tax($price, $tax) { return $price * $tax / 100; } //// // Returns the tax rate for a zone / class // TABLES: tax_rates, zones_to_geo_zones function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) { global $customer_zone_id, $customer_country_id; if ( ($country_id == -1) && ($zone_id == -1) ) { if (!tep_session_is_registered('customer_id')) { $country_id = STORE_COUNTRY; $zone_id = STORE_ZONE; } else { $country_id = $customer_country_id; $zone_id = $customer_zone_id; } } $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za ON tr.tax_zone_id = za.geo_zone_id left join " . TABLE_GEO_ZONES . " tz ON tz.geo_zone_id = tr.tax_zone_id WHERE (za.zone_country_id IS NULL OR za.zone_country_id = '0' OR za.zone_country_id = '" . (int)$country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . (int)$zone_id . "') AND tr.tax_class_id = '" . (int)$class_id . "' GROUP BY tr.tax_priority"); if (tep_db_num_rows($tax_query)) { $tax_multiplier = 0; while ($tax = tep_db_fetch_array($tax_query)) { $tax_multiplier += $tax['tax_rate']; } return $tax_multiplier; } else { return 0; } } //// // Returns the tax rate for a tax class // TABLES: tax_rates function tep_get_tax_rate_value($class_id) { $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '" . (int)$class_id . "' group by tax_priority"); if (tep_db_num_rows($tax_query)) { $tax_multiplier = 0; while ($tax = tep_db_fetch_array($tax_query)) { $tax_multiplier += $tax['tax_rate']; } return $tax_multiplier; } else { return 0; } } function tep_call_function($function, $parameter, $object = '') { if ($object == '') { return call_user_func($function, $parameter); } elseif (PHP_VERSION < 4) { return call_user_method($function, $object, $parameter); } else { return call_user_func(array($object, $function), $parameter); } } function tep_get_zone_class_title($zone_class_id) { if ($zone_class_id == '0') { return TEXT_NONE; } else { $classes_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$zone_class_id . "'"); $classes = tep_db_fetch_array($classes_query); return $classes['geo_zone_name']; } } function tep_cfg_pull_down_zone_classes($zone_class_id, $key = '') { $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value'); $zone_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); $zone_class_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name"); while ($zone_class = tep_db_fetch_array($zone_class_query)) { $zone_class_array[] = array('id' => $zone_class['geo_zone_id'], 'text' => $zone_class['geo_zone_name']); } return tep_draw_pull_down_menu($name, $zone_class_array, $zone_class_id); } function tep_cfg_pull_down_order_statuses($order_status_id, $key = '') { global $languages_id; $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value'); $statuses_array = array(array('id' => '0', 'text' => TEXT_DEFAULT)); $statuses_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_name"); while ($statuses = tep_db_fetch_array($statuses_query)) { $statuses_array[] = array('id' => $statuses['orders_status_id'], 'text' => $statuses['orders_status_name']); } return tep_draw_pull_down_menu($name, $statuses_array, $order_status_id); } function tep_get_order_status_name($order_status_id, $language_id = '') { global $languages_id; if ($order_status_id < 1) return TEXT_DEFAULT; if (!is_numeric($language_id)) $language_id = $languages_id; $status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$order_status_id . "' and language_id = '" . (int)$language_id . "'"); $status = tep_db_fetch_array($status_query); return $status['orders_status_name']; } //// // Return a random value function tep_rand($min = null, $max = null) { static $seeded; if (!$seeded) { mt_srand((double)microtime()*1000000); $seeded = true; } if (isset($min) && isset($max)) { if ($min >= $max) { return $min; } else { return mt_rand($min, $max); } } else { return mt_rand(); } } // nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n) function tep_convert_linefeeds($from, $to, $string) { if ((PHP_VERSION < "4.0.5") && is_array($from)) { return ereg_replace('(' . implode('|', $from) . ')', $to, $string); } else { return str_replace($from, $to, $string); } } function tep_string_to_int($string) { return (int)$string; } //// // Parse and secure the cPath parameter values function tep_parse_category_path($cPath) { // make sure the category IDs are integers $cPath_array = array_map('tep_string_to_int', explode('_', $cPath)); // make sure no duplicate category IDs exist which could lock the server in a loop $tmp_array = array(); $n = sizeof($cPath_array); for ($i=0; $i<$n; $i++) { if (!in_array($cPath_array[$i], $tmp_array)) { $tmp_array[] = $cPath_array[$i]; } } return $tmp_array; } //// bof sort order & quantity change //// // Sets the sort order of a product function tep_set_product_sort_order($products_id, $sort_order) { return tep_db_query("update " . TABLE_PRODUCTS . " set products_sort_order = '" . $sort_order . "', products_last_modified = now() where products_id = '" . (int)$products_id . "'"); } // Function Category Sort Order function tep_set_cat_sort_order($categories_id, $sort_order) { return tep_db_query("update " . TABLE_CATEGORIES . " set sort_order = '" . $sort_order . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'"); } // Function Quantity Update function tep_set_qty_update($products_id, $sort_order) { return tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $sort_order . "', products_last_modified = now() where products_id = '" . (int)$products_id . "'"); } //// eof sort order & quantity change //// //-MS- Added active countries //// // Sets the status of a country function tep_set_country_status($countries_id, $status) { if ($status == '1') { return tep_db_query("update " . TABLE_COUNTRIES . " set countries_status = '1' where countries_id = '" . (int)$countries_id . "'"); } elseif ($status == '0') { return tep_db_query("update " . TABLE_COUNTRIES . " set countries_status = '0' where countries_id = '" . (int)$countries_id . "'"); } else { return -1; } } //// // Sets the status of a state function tep_set_zone_status($zone_id, $status) { if ($status == '1') { return tep_db_query("update " . TABLE_ZONES . " set zone_status = '1' where zone_id = '" . (int)$zone_id . "'"); } elseif ($status == '0') { return tep_db_query("update " . TABLE_ZONES . " set zone_status = '0' where zone_id = '" . (int)$zone_id . "'"); } else { return -1; } } //// // Sets the pay status of a country function tep_set_country_pay_status($countries_id, $status) { if ($status == '1') { return tep_db_query("update " . TABLE_COUNTRIES . " set countries_pay_status = '1' where countries_id = '" . (int)$countries_id . "'"); } elseif ($status == '0') { return tep_db_query("update " . TABLE_COUNTRIES . " set countries_pay_status = '0' where countries_id = '" . (int)$countries_id . "'"); } else { return -1; } } //// // Sets the status of a country function tep_set_country_ship_status($countries_id, $status) { if ($status == '1') { return tep_db_query("update " . TABLE_COUNTRIES . " set countries_ship_status = '1' where countries_id = '" . (int)$countries_id . "'"); } elseif ($status == '0') { return tep_db_query("update " . TABLE_COUNTRIES . " set countries_ship_status = '0' where countries_id = '" . (int)$countries_id . "'"); } else { return -1; } } //// // Returns an array of active countries function tep_get_active_countries($countries_array = '') { if (!is_array($countries_array)) $countries_array = array(); //PHP 4.x Bug, not init as local var automatically with a global present? $countries_query = ''; $countries_query = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " where countries_status = '1' order by countries_name"); while( $countries = tep_db_fetch_array($countries_query) ) { $countries_array[] = array('id' => $countries['countries_id'], 'text' => $countries['countries_name']); } return $countries_array; } //-MS- Added active countries EOM ////// Function For Product Attributes (Shipping Wieght Work is Also Included) function getProductAttributesVaules($str) { $str1 = explode('_',$str); $option_id = $str1[1]; $option_value_id= $str1[0]; if(isset($_REQUEST['pID']) && $_REQUEST['action']=='new_product') { //print_r($_REQUEST);exit; $pid = $_REQUEST['pID']; $query = tep_db_query('select * from '.TABLE_PRODUCTS_ATTRIBUTES.' where options_id='.(int)$option_id.' and options_values_id='.(int)$option_value_id.' and products_id='.(int)$pid); $result = tep_db_fetch_array($query); //print_r($result); $att = array( 'options_id' => $result['options_id'], 'options_values_id' => $result['options_values_id'], 'options_values_price' => $result['options_values_price'], 'price_prefix' => $result['price_prefix'], 'attribute_weight' =>$result['attribute_weight'] ///// Optional ) ; // print_r($att); return $att; } elseif (isset($_REQUEST['pID']) && $_REQUEST['action']=='update_product') { $textbox = 'txt_'.$str; $select = 'select_'.$str; $weight = 'weight_'.$str; /// Optional $att = array ( 'options_id' => $option_id, 'options_values_id' => $option_value_id, 'options_values_price' => $_REQUEST[$textbox], 'price_prefix' => $_REQUEST[$select] , 'attribute_weight' => $_REQUEST[$weight] /// Optional ); return $att; } else if ($_REQUEST['action']=='insert_product') { $textbox = 'txt_'.$str; $select = 'select_'.$str; $weight = 'weight_'.$str; /// Optional $att = array ( 'options_id' => $option_id, 'options_values_id' => $option_value_id, 'options_values_price' => $_REQUEST[$textbox], 'price_prefix' => $_REQUEST[$select], 'attribute_weight' => $_REQUEST[$weight] /// Optional ); return $att; } } ////////// function tep_cfg_readonly($value){ $single[]= array('id' => $value, 'text' => $value); return tep_draw_pull_down_menu('configuration_value', $single, $value); } function tep_cfg_pull_down_installed_fonts($font_name) { if ($root=@opendir(DIR_FS_DOCUMENT_ROOT.'includes/imagemagic/fonts')){ while ($file=readdir($root)){ if($file=="." || $file==".." || is_dir($dir."/".$file)) continue; $files[]= array('id' => $file, 'text' => $file); } } return tep_draw_pull_down_menu('configuration_value', $files, $font_name); } function tep_cfg_pull_down_installed_watermarks($watermark_name) { if ($root=@opendir(DIR_FS_DOCUMENT_ROOT.'includes/imagemagic/watermarks')){ while ($file=readdir($root)){ if($file=="." || $file==".." || is_dir($dir."/".$file)) continue; $files[]= array('id' => $file, 'text' => $file); } } return tep_draw_pull_down_menu('configuration_value', $files, $watermark_name); } function tep_cfg_pull_down_watermark_alignment($watermark_alignment) { $align[]= array('id' => 'Tiled', 'text' => 'Tiled'); $align[]= array('id' => 'Top', 'text' => 'Top'); $align[]= array('id' => 'Top Left', 'text' => 'Top Left'); $align[]= array('id' => 'Top Right', 'text' => 'Top Right'); $align[]= array('id' => 'Center', 'text' => 'Center'); $align[]= array('id' => 'Bottom', 'text' => 'Bottom'); $align[]= array('id' => 'Bottom Left', 'text' => 'Bottom Left'); $align[]= array('id' => 'Bottom Right', 'text' => 'Bottom Right'); return tep_draw_pull_down_menu('configuration_value', $align, $watermark_alignment); } ?> Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/nakedpla/public_html/admin/includes/functions/general.php:18) in /home/nakedpla/public_html/admin/includes/functions/sessions.php on line 102 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/nakedpla/public_html/admin/includes/functions/general.php:18) in /home/nakedpla/public_html/admin/includes/functions/sessions.php on line 102 Fatal error: Call to undefined function tep_not_null() in /home/nakedpla/public_html/admin/includes/classes/language.php on line 74 Second Problem: When I try to view a product on the actual shop, I get a "Parse error: syntax error, unexpected T_ELSE in /home/**********/public_html/product_info.php on line 259" Any ideas on how to fix either one? If I remember right, the admin/index.php file wasn't edited at all, so why would it throw error messages?
  8. However, I am having another issue: (and sorry for all the extra posting--it wouldn't allow me to edit/update the previous post) When it comes to checking out, the module doesn't work. Here's what I'm trying to do: There are certain items that are supposed to be shipped locally (or within a certain zone) only. However, when those items are in the cart and I try to check out with a non-local shipping address, I am still able to checkout. I want to restrict it so if someone outside of the local shipping zone tries to checkout one of the restricted shipping items, they won't be able to--there will be an error message or something. Are there other settings that need to be changed?
  9. Update: Nevermind, I figured out the issue. I had to remove/reinstall the Table module for the new sections to show up properly. >_<
  10. I think this contrib is exactly what I needed, though I'm having one problem: I can't seem to implement it correctly with the Table Rate Shipping module. I'm not getting any error messages. The problem is, there are 2 new (empty) fields in the module now, but no indication of content.: I'm not sure if I did the implementation correctly. I basically took the code/instructions for the Flat Rate module, and just used the Table module and switched all the "FLAT" parts of the code to "TABLE". Here's the code: <?php /* $Id: table.php,v 1.26x 2003/01/31 $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce * Modifications by Christian Lescuyer <[email protected]> * Copyright (c) 2003 Goélette http://www.goelette.net Released under the GNU General Public License */ class table { var $code, $title, $description, $icon, $enabled; // class constructor function table() { global $order; $this->code = 'table'; $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE; $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER; $this->icon = ''; $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false); $this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS; if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } //-MS- Active Shipping Added if( $this->enabled == true && function_exists('tep_check_active_zone') ) { $this->enabled = tep_check_active_zone(MODULE_SHIPPING_TABLE_ACTIVE_ZONE, MODULE_SHIPPING_TABLE_ACTIVE_MODE); } //-MS- Active Shipping Added EOM } // class methods function quote($method = '') { global $cart, $shipping_weight, $shipping_num_boxes; if (MODULE_SHIPPING_TABLE_MODE == 'price') { $order_total = $cart->show_total(); } else if (MODULE_SHIPPING_TABLE_MODE == 'count') { $order_total = $cart->count_contents(); } else { $order_total = $shipping_weight; } $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST); $size = sizeof($table_cost); for ($i=0, $n=$size; $i<$n; $i+=2) { if ($order_total <= $table_cost[$i]) { $shipping = $table_cost[$i+1]; break; } } if (MODULE_SHIPPING_TABLE_MODE == 'weight') { $shipping = $shipping * $shipping_num_boxes; } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_TABLE_TEXT_WAY, 'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING))); if ( $this->tax_class > 0 ) { $this->quotes['tax'] = tep_get_tax_rate( $this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id'] ); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total weight, cost or number of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE_MODE', 'weight', 'The shipping cost is based on the total weight, or the order total, or the number of items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); //-MS- Active Shipping Added tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Active Shipping', 'MODULE_SHIPPING_TABLE_ACTIVE_ZONE', '0', 'Use the following active zone to activate the module based on categories-products.', '6', '0', 'tep_get_active_zone_title', 'tep_cfg_pull_down_active_zones(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Mode of Operation', 'MODULE_SHIPPING_TABLE_ACTIVE_MODE', 'Inclusive', 'Inclusive: Enables the module if one product is found to be covered by the active zone.<br>Exclusive: Enables the module if all products in the cart are covered by the active zone', '6', '0', 'tep_cfg_select_option(array(\'Inclusive\', \'Exclusive\'), ', now())"); //-MS- Active Shipping Added EOM tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_TABLE_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); tep_db_query( "insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())" ); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { //-MS- Active Shipping Added return array('MODULE_SHIPPING_TABLE_STATUS', 'MODULE_SHIPPING_TABLE_COST', 'MODULE_SHIPPING_TABLE_TAX_CLASS', 'MODULE_SHIPPING_TABLE_ZONE', 'MODULE_SHIPPING_TABLE_ACTIVE_ZONE', 'MODULE_SHIPPING_TABLE_ACTIVE_MODE', 'MODULE_SHIPPING_TABLE_SORT_ORDER'); //-MS- Active Shipping Added EOM } } ?>
  11. Ok, Easy Populate is an awesome contribution and works great at uploading a lot of products. However.. I'm having one problem with it: adding The Product Images. Adding the images is not the problem. The problem is they aren't automatically re-sized into thumbnails, like they would be if you uploaded a product image through the admin panel. So, instead of having a shopping cart with thumbnail images that you can click to view the bigger images, all that shows up on mine are the bigger images--no thumbnails at all. I'm not sure how to add an extra column to the CSV for thumbnail purposes (or if it's even necessary/possible). I tried leaving the image column on the CSV empty and just uploading the image through the admin panel as usual. They still show up large. Same happens when its done via FTP. And I haven't changed the small image settings, either. So... I'm not sure what the deal is or how to fix it, but any help would be appreciated! As a side note, I haven't received any kind of errors, so I don't know how else to get the thumbnails to work...or what else may be the problem... :blink:
  12. Ok, I just installed this and... it doesn't work. At all. The version I downloaded/installed is the March 9, 2009 Full Package (v.2.1). I followed all of the instructions in the Install Guide text, and even double and triple checked all of the code/files to make sure I had it done right. And it still doesn't work. What do I mean by "it doesn't work"? Well, there is no dummy or guest account. There is no way for a customer to make a purchase without creating an account. In other words, anyone who would want to buy something, would still have to create an account. Its as if the PWA was never even installed. If there is anything that needs to be done in the admin panel, that would be nice to know because there's no instructions for that in any of the installation files. And yes, I've cleared my cache and there is still no change. This is very frustrating.
×
×
  • Create New...