Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

User Notification upon new related product


Tom172

Recommended Posts

Hello.

 

In a 2.2rc2a oscommerce shop. I´m using the 3152 Auto Stock Notification Contribution to auto inform users of stock updates i.e. when a product becomes available.

 

I have slightly modified the contribution to inform users with a 2nd automated email if a product's description has been updated/changed.

 

 

Now I was trying to modify the same contribution so that a customer is beeing auto notified if a product on his watchlist gets a new related product. In my case that means if another accessory becomes available to that product.

 

 

For linking products to eachother I am using optional related products contribution Link.

 

 

My thoughts were to take the code from auto notification (that goes into admin/categories.php) and implement it into admin/optional_related_products.php)

 

Unfortunately this wouldn´t work. At least I wasn´t able get it to work.

 

So my question is, if anyone could help me to get these few lines to work in the following file so that it sends out an email (taken from product_notifications Table) to the customer once a new related product is beeing added to an existing and watched product.

 

in the following optional_related_products.php file the master product would be the existing and watched product and the slave would be the new accessory.

 

 

Code from 3152 Auto Stock Notification

In catalog/admin/categories.php

FIND this:

           tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");
         } elseif ($action == 'update_product') {

Insert this directly AFTER it:

// BEGIN Automatic Stock Notification
		$current_stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$_GET['pID'] . "'");
		$current_stock = tep_db_fetch_array($current_stock_query);
		if ($current_stock['products_quantity'] < 1) {
		  if ($_POST['products_quantity'] > 0) {
			$audience = array();
			$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");

			while ($products = tep_db_fetch_array($products_query)) {
			  $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
														   'lastname' => $products['customers_lastname'],
														   'email_address' => $products['customers_email_address']);
			}

			$product_query_raw = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$_GET['pID'] . "'");
			$product = tep_db_fetch_array($product_query_raw);

			$customers_query_raw = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");
			$customer = tep_db_fetch_array($customers_query_raw);

			reset($audience);
			while (list($key, $value) = each ($audience)) {
			  $mimemessage = new email(array('X-Mailer: osCommerce System Mailer'));
			  // add the message to the object
			  if (EMAIL_USE_HTML == 'true') {
				$mimemessage->add_html(HTML_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . HTML_NOTIFICATION2 . STORE_NAME . HTML_NOTIFICATION3 . $products_id . '">' . $product['products_name'] . HTML_NOTIFICATION4 . '">' . STORE_NAME . HTML_NOTIFICATION5 . STORE_NAME);
			  } else {
				$mimemessage->add_text(TEXT_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . TEXT_NOTIFICATION2 . STORE_NAME . TEXT_NOTIFICATION3 . $product['products_name'] . TEXT_NOTIFICATION4 . STORE_NAME);
			  }
			  $mimemessage->build_message();
			  $mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT . $product['products_name'], $email_order);
			}
		  }
		}
// END Automatic Stock Notification

 

(This is just step 2 of the contribution and of course we drop the current stock querry)

 

 

And here is the optional_related_products.php File where I think the above code should go somewhere close to the case 'Insert' and/or case 'Reciprocate':

 

 

<?php
/*
 $Id: optional_related_products.php, ver 1.0 02/05/2007 Exp $

 Copyright (c) 2007 Anita Cross (http://www.callofthewildphoto.com/)

 Based on: products_options.php, ver 2.0 05/01/2005
 Copyright (c) 2004-2005 Daniel Bahna ([email protected])

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

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
 $languages = tep_get_languages();

/**  $version = tep_db_fetch_array(tep_db_query("select configuration_value as version, configuration_group_id as gID from " . TABLE_CONFIGURATION . " where configuration_key = 'RELATED_PRODUCTS_VERSION_INSTALLED'"));
 if ($version['version'] != TEXT_VERSION_CONTROL){
   tep_redirect(tep_href_link('sql_setup_related_products.php'));
 }
 $gID = $version['gID']; **/

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 $products_id_view = $HTTP_GET_VARS['products_id_view'];
 $products_id_master = $HTTP_GET_VARS['products_id_master'];
 if ($products_id_master) { $products_id_view = $products_id_master; }

 if (tep_not_null($action)) {
   $page_info = '';
   if (isset($HTTP_GET_VARS['attribute_page'])) $page_info .= 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] . '&';
   if (tep_not_null($page_info)) {
     $page_info = substr($page_info, 0, -1);
   }

   switch ($action) {
     case 'Insert':
       $products_id_master = tep_db_prepare_input($_REQUEST['products_id_master']);
       $products_id_slave = tep_db_prepare_input($_REQUEST['products_id_slave']);
       $pop_order_id = tep_db_prepare_input($_REQUEST['pop_order_id']);

       if ($products_id_master != $products_id_slave) {
         $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_master ." and p.pop_products_id_slave=" . $products_id_slave);
         if (!tep_db_fetch_array($check)) {
           tep_db_query("insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_master . "', '" . (int)$products_id_slave . "', '". (int)$pop_order_id."')");
         }
       }
       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_master='.$products_id_master.'&products_id_slave='.$products_id_slave.'&products_id_view='.$products_id_view));
       break;

     case 'Reciprocate':
       $products_id_master = tep_db_prepare_input($_REQUEST['products_id_master']);
       $products_id_slave = tep_db_prepare_input($_REQUEST['products_id_slave']);
       $pop_order_id = tep_db_prepare_input($_REQUEST['pop_order_id']);
       if ($products_id_master != $products_id_slave) {
         $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_master ." and p.pop_products_id_slave=" . $products_id_slave);
         if (!tep_db_fetch_array($check)) {
           tep_db_query("insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_master . "', '" . (int)$products_id_slave . "', '". (int)$pop_order_id."')");
         }
         $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_slave ." and p.pop_products_id_slave=" . $products_id_master );
         if (!tep_db_fetch_array($check)) {
           tep_db_query("insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_slave . "', '" . (int)$products_id_master . "', '". (int)$pop_order_id."')");
         }
       }
       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_master='.$products_id_master.'&products_id_slave='.$products_id_slave.'&products_id_view='.$products_id_view));
       break;

     case 'Inherit':
       $products_id_master = tep_db_prepare_input($_REQUEST['products_id_master']);
       $products_id_slave = tep_db_prepare_input($_REQUEST['products_id_slave']);
       $pop_order_id = tep_db_prepare_input($_REQUEST['pop_order_id']);

       if ($products_id_master != $products_id_slave) {
         if (INSERT_AND_INHERIT == 'True') {
           $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_master." and p.pop_products_id_slave=" . $products_id_slave);
           if (!tep_db_fetch_array($check)) {
              tep_db_query("insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_master . "', '" . (int)$products_id_slave . "', '". (int)$pop_order_id."')");
           }
         }
         $products = tep_db_query("select p.pop_products_id_slave from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_slave . " order by p.pop_id");
         while ($products_values = tep_db_fetch_array($products)) {
           $products_id_slave2 = $products_values['pop_products_id_slave'];
           if ($products_id_master != $products_id_slave2) {

             $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_master." and p.pop_products_id_slave=" . $products_id_slave2);
             if (!tep_db_fetch_array($check)) {
               tep_db_query(" insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_master . "', '" . (int)$products_id_slave2 . "', '". (int)$pop_order_id."')");
             }
           }
         }
       }
       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_master='.$products_id_master.'&products_id_slave='.$products_id_slave.'&products_id_view='.$products_id_view));
       break;

     case 'update_product_attribute':
       $products_id_master = tep_db_prepare_input($_REQUEST['products_id_master']);
       $products_id_slave = tep_db_prepare_input($_REQUEST['products_id_slave']);
       $pop_order_id = tep_db_prepare_input($_REQUEST['pop_order_id']);
       $pop_id = tep_db_prepare_input($_REQUEST['pop_id']);

       tep_db_query("update " . TABLE_PRODUCTS_RELATED_PRODUCTS . " set pop_products_id_master = '" . (int)$products_id_master . "', pop_products_id_slave = '" . (int)$products_id_slave . "', pop_order_id = '".(int)$pop_order_id."' where pop_id = '" . (int)$pop_id . "'");
       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_view='.$products_id_view));
       break;
     case 'delete_attribute':
       $pop_id = tep_db_prepare_input($HTTP_GET_VARS['pop_id']);

       tep_db_query("delete from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " where pop_id = '" . (int)$pop_id . "'");

       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_view='.$products_id_view));
       break;
   }
 }
?>
<!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>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<?php require(DIR_WS_INCLUDES . 'header.php'); /* header */?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<?php require(DIR_WS_INCLUDES . 'column_left.php'); /* left navigation */ ?>
   </table></td>
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

     </tr>
     <tr>
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"> <?php echo HEADING_TITLE_ATRIB; ?> </td>
           <td><form name="formview"><select name="products_id_view" onChange="return formview.submit();">
<?php

   echo '<option name="Show All Products" value="">Show All Products</option>';
   $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
   while ($products_values = tep_db_fetch_array($products)) {
       $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
       $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
       if ($products_id_view == $products_values['products_id']) {
             echo '<option name="' . $name . '" value="' . $products_values['products_id'] . '" SELECTED>' . $model . $name . '</option>';
       } else {
             echo '<option name="' . $name . '" value="' . $products_values['products_id'] . '">' . $model . $name . '</option>';
       }
   }
?>
           </select></form> </td>
           <td><?php ?> </td>
           <td><a href="<?php ?>"></a><br>
               <a href="<?php ?>"></a>
           </td>
         </tr>
       </table></td>
     </tr>
     <tr> 

<?php
/*
foreach ($_REQUEST as $key => $value) {
  echo "Key: $key; Value: $value<br>\n";
}
*/
 if ($action == 'update_attribute') {
   $form_action = 'update_product_attribute';
 } else {
   $form_action = 'add_product_attributes';
 }

 if (!isset($attribute_page)) {
   $attribute_page = 1;
 }
 $prev_attribute_page = $attribute_page - 1;
 $next_attribute_page = $attribute_page + 1;
 $form_params = 'action=' . $form_action . '&option_page=' . $option_page . '&value_page=' . $value_page . '&attribute_page=' . $attribute_page;
?>
       <td><form name="attributes" action="<?php echo tep_href_link(FILENAME_RELATED_PRODUCTS, $form_params); ?>" method="get"><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td colspan="5" class="smallText">
<?php
 $per_page = RELATED_PRODUCTS_MAX_ROW_LISTS_OPTIONS;

 $attributes = "
        SELECT
               pa.*
          FROM " .
               TABLE_PRODUCTS_RELATED_PRODUCTS . " pa
          LEFT JOIN " .
               TABLE_PRODUCTS_DESCRIPTION . " pd
            ON pa.pop_products_id_master = pd.products_id
           AND pd.language_id = '" . (int)$languages_id . "'";

 if ($products_id_view) { $attributes .= "
         WHERE pd.products_id = '$products_id_view'"; }
 $attributes .= "
      ORDER BY pd.products_name, pa.pop_order_id, pa.pop_id";

 $attribute_query = tep_db_query($attributes);

 $attribute_page_start = ($per_page * $attribute_page) - $per_page;
 $num_rows = tep_db_num_rows($attribute_query);

 if ($num_rows <= $per_page) {
    $num_pages = 1;
 } else if (($num_rows % $per_page) == 0) {
    $num_pages = ($num_rows / $per_page);
 } else {
    $num_pages = ($num_rows / $per_page) + 1;
 }
 $num_pages = (int) $num_pages;

 $attributes = $attributes . " LIMIT $attribute_page_start, $per_page";

 $view_id = '';
 if ($products_id_view) {
   $products_id_view = $products_id_master?$products_id_master:$products_id_view;
   $view_id = '&products_id_view=' . $products_id_view;
 }

 // Previous
 if ($prev_attribute_page) {
   echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, 'attribute_page=' . $prev_attribute_page . $view_id) . '"> << </a> | ';
 }

 for ($i = 1; $i <= $num_pages; $i++) {
   if ($i != $attribute_page) {
     echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, 'attribute_page=' . $i) . $view_id . '">' . $i . '</a> | ';
   } else {
     echo '<b><font color="red">' . $i . '</font></b> | ';
   }
 }

 // Next
 if ($attribute_page != $num_pages) {
   echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, 'attribute_page=' . $next_attribute_page . $view_id) . '"> >> </a>';
 }
?>
           </td>
         </tr>
         <tr>
           <td colspan="5"><?php echo tep_black_line(); ?></td>
         </tr>
         <tr class="dataTableHeadingRow">
           <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>
           <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?>(To) </td>
           <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?>(From) </td>
           <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ORDER; ?> </td>
           <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>
         </tr>
         <tr>
           <td colspan="5"><?php echo tep_black_line(); ?></td>
         </tr>
<?php
 $next_id = 1;
 $attributes = tep_db_query($attributes);
 while ($attributes_values = tep_db_fetch_array($attributes)) {
   $products_name_master = tep_get_products_name($attributes_values['pop_products_id_master']);
   $products_name_slave = tep_get_products_name($attributes_values['pop_products_id_slave']);
   if (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True') {
     $mModel = tep_get_products_model($attributes_values['pop_products_id_master']) . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR . ' ';
     $sModel = tep_get_products_model($attributes_values['pop_products_id_slave']) . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR . ' ';
   } else {
     $mModel = $sModel = '';
   }
   $pop_order_id = $attributes_values['pop_order_id'];
   $rows++;
?>
         <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
   if (($action == 'update_attribute') && ($HTTP_GET_VARS['pop_id'] == $attributes_values['pop_id'])) {
?>
           <td class="smallText"> <?php echo $attributes_values['pop_id']; ?><input type="hidden" name="pop_id" value="<?php echo $attributes_values['pop_id']; ?>"> </td>
           <td class="smallText"> <select name="products_id_master">
<?php
     $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
     while($products_values = tep_db_fetch_array($products)) {
       $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
       $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
       $product_name = (RELATED_PRODUCTS_MAX_NAME_LENGTH == '0')?$name:substr($name, 0, RELATED_PRODUCTS_MAX_NAME_LENGTH);
       if ($attributes_values['pop_products_id_master'] == $products_values['products_id']) {
         echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $model . $product_name . '</option>';
       } else {
         echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $model . $product_name . '</option>';
       }
     }
?>
           </select> </td>
           <td class="smallText"> <select name="products_id_slave">
<?php
     $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
     while($products_values = tep_db_fetch_array($products)) {
       $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
       $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
       $product_name = (RELATED_PRODUCTS_MAX_NAME_LENGTH == '0')?$name:substr($name, 0, RELATED_PRODUCTS_MAX_NAME_LENGTH);
       if ($attributes_values['pop_products_id_slave'] == $products_values['products_id']) {
         echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $model . $product_name . '</option>';
       } else {
         echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $model . $product_name . '</option>';
       }
     }
?>
           </select> </td>
           <td align="center" class="smallText"> <input type="text" name="pop_order_id" value="<?php echo $attributes_values['pop_order_id']; ?>" size="6"> </td>
           <td align="center" class="smallText"> <input type="hidden" name="action" value="update_product_attribute"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?> <?php echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, '&attribute_page=' . $attribute_page . '&products_id_view='.$products_id_view, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a> </td>
<?php
   } else {
//  basic browse table list
?>
           <td class="smallText"> <?php echo $attributes_values["pop_id"]; ?> </td>
           <td class="smallText"> <?php echo $mModel ?><?php echo (RELATED_PRODUCTS_MAX_DISPLAY_LENGTH== '0')?$products_name_master:substr($products_name_master, 0, RELATED_PRODUCTS_MAX_DISPLAY_LENGTH); ?> </td>
           <td class="smallText"> <?php echo $sModel ?><?php echo (RELATED_PRODUCTS_MAX_DISPLAY_LENGTH== '0')?$products_name_slave:substr($products_name_slave, 0, RELATED_PRODUCTS_MAX_DISPLAY_LENGTH); ?> </td>
           <td class="smallText" align="center"> <?php echo $pop_order_id; ?> </td>
           <td align="center" class="smallText">

              <?php
                $params = 'action=update_attribute&pop_id='
                         . $attributes_values['pop_id']
                         . '&attribute_page=' . $attribute_page
                         . '&products_id_view=' . $products_id_view;
                    echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, $params, 'NONSSL') . '">'; ?>
                    Edit</a>  
              <?php
                $params = 'action=delete_attribute&pop_id='
                         . $attributes_values['pop_id']
                         . '&attribute_page=' . $attribute_page
                         . '&products_id_view=' . $products_id_view;
                    if (RELATED_PRODUCTS_CONFIRM_DELETE == 'False') { ?>
              <a href="<?php echo tep_href_link(FILENAME_RELATED_PRODUCTS, $params, 'NONSSL')?>">Delete</a>
              <?php }else { ?>
              <a href="<?php echo tep_href_link(FILENAME_RELATED_PRODUCTS, $params, 'NONSSL')?>" onclick="return confirm('<?php echo sprintf(TEXT_CONFIRM_DELETE_ATTRIBUTE, addslashes($products_name_slave), addslashes($products_name_master)); ?>');">Delete</a>
              <?php } ?></td>
<?php
   }
   $max_attributes_id_query = tep_db_query("select max(pop_id) + 1 as next_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS);
   $max_attributes_id_values = tep_db_fetch_array($max_attributes_id_query);
   $next_id = $max_attributes_id_values['next_id'];
?>
         </tr>
<?php
 }
 if ($action != 'update_attribute') {
?>
         <tr>
           <td colspan="5"><?php echo tep_black_line(); ?></td>
         </tr>
         <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
           <td class="smallText"> <?php echo $next_id; ?> </td>
     	    <td class="smallText"><b>A:</b> <select name="products_id_master">
<?php
   $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
   $products_id_master = $HTTP_GET_VARS['products_id_master'];
   if (!$products_id_master) { $products_id_master = $products_id_view; }
   while ($products_values = tep_db_fetch_array($products)) {
     $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
     $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
     $product_name = (RELATED_PRODUCTS_MAX_NAME_LENGTH == '0')?$name:substr($name, 0, RELATED_PRODUCTS_MAX_NAME_LENGTH);
     if ($products_id_master == $products_values['products_id']) {
       echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $model . $product_name . '</option>';
     } else {
       echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $model . $product_name . '</option>';
     }
   }
?>
           </select> </td>
           <td class="smallText"><b>B:</b> <select name="products_id_slave">
<?php
   $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
   while ($products_values = tep_db_fetch_array($products)) {
     $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
     $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
     $product_name = (RELATED_PRODUCTS_MAX_NAME_LENGTH == '0')?$name:substr($name, 0, RELATED_PRODUCTS_MAX_NAME_LENGTH);
     if ($HTTP_GET_VARS['products_id_slave'] == $products_values['products_id']) {
       echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $model . $product_name . '</option>';
     } else {
       echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $model . $product_name . '</option>';
     }
   }
?>
           </select> </td>
           <td class="smallText" align="center"> <input type="text" name="pop_order_id" size="3"> </td>
         </tr>
         <tr><td colspan="5" align="center" class="smallText">
           <input type="submit" name="action" value="Insert">
           <input type="submit" name="action" value="Reciprocate">
           <input type="submit" name="action" value="Inherit">
         </td></tr>
<?php
 }
?>
         <tr>
           <td colspan="5"><?php echo tep_black_line(); ?></td>
         </tr>
       </table>
       <input type="hidden" name="products_id_view" value="<?php echo $products_id_view; ?>">
       </form></td>
     </tr>
   </table></td>
 </tr>
</table>
<?php require(DIR_WS_INCLUDES . 'footer.php'); /* footer */?>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Any help will be appreciated.

Thanks

Tom

Link to comment
Share on other sites

I would also appreciate a hint how to start, as I have tried now for several days. Maybee this approach won´t work at all, then If someone could tell me "stop trying" .. would maybe best advice ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...