Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Distinguishing Products ID Pages


carlost

Recommended Posts

Posted

Does anyone know if it is possible to add an "if" statement to the products_info.php file, in order to remove the "reviews" button for some products, and not for others?

 

I have tried:

 

"if (basename($PHP_SELF) == 'product_info.php?products_id=37') {"

 

and

 

if (basename($PHP_SELF) == FILENAME_PRODUCT_INFO . 'products_id=37') {

 

Neither works.

 

Any input would be much appreciated.

 

Thanks in advance,

 

Carlos

Posted

I figured out a way that works. I'll try to explain what I did, in case someone else has an interest.

 

I used a data base query (I think), which I found being used for another purpose, and which I used some common sense, and a lot of trial and error - to modify some, to use for my purpose.

 

I placed the following code before the area, which I wanted to show if the specific product ID involved was called for:

 

<?php 
   $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
   $products = tep_db_fetch_array($products_query);
   if ($products['products_id'] == 37) {
?>

 

Product ID 37 being the product involved.

 

Then I placed this following code before the area, which I wanted to show if any other product was called for:

 

<?php
 } else {
   if ($products['products_id'] != 37) {
?>

 

Then I placed this following code directly after both, separate areas that I wanted to show, (depending on, which product ID was called for):

 

<?php
}
}
?>

 

To further explain: I have both the gift voucher contribution, and the wishlist contribution installed.

 

The gift voucher contribution requires that a "Gift Certificate" product be entered in the normal way.

 

The "Gift Certificate" product showed the "Review" & "Add to Wish List" buttons, just like every other product does, and I did not want this, as neither function makes any sense for a "Gift Certificate".

 

However, I did want the "Review" & "Add to Wish List" buttons to show with all other products.

 

I hope my explanation makes some sense to anyone else who wants to do something similar with the product_info.php file. I know how frustrating it can be to not understand what those who know a subject understand readily. I don't know much about all this, and am often frustrated in the course of my learning more by reading this forum.

 

Anyways, to possibly further help, here is the code exactly as it appears in my product_info.php file:

 

<td>

<?php 
   $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
   $products = tep_db_fetch_array($products_query);
   if ($products['products_id'] == 37) {
?>

<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="center" class="main"></td>
               <?php
       $nononline_items = array();
       $sql = "SELECT manufacturers_id FROM manufacturers WHERE disable_addtobasket='Y'";
       $result = mysql_query($sql);
       while($id = mysql_fetch_array($result,MYSQL_ASSOC)){
               array_push($nononline_items,$id['manufacturers_id']);
       }

      if (!in_array($product_info['manufacturers_id'],$nononline_items)){
            echo ("   <td class=\"main\" align=\"center\">". tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_template_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART));
      }
      else {
 echo (" <td class=\"main\" align=\"right\">".NON_ONLINE_ITEM);
      }  
      ?></form></td>
              <td align="center" class="main"></td></form>
              <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
</table>

<?php
 } else {
   if ($products['products_id'] != 37) {
?>

<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="center" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_template_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
               <?php
       $nononline_items = array();
       $sql = "SELECT manufacturers_id FROM manufacturers WHERE disable_addtobasket='Y'";
       $result = mysql_query($sql);
       while($id = mysql_fetch_array($result,MYSQL_ASSOC)){
               array_push($nononline_items,$id['manufacturers_id']);
       }

      if (!in_array($product_info['manufacturers_id'],$nononline_items)){
            echo ("   <td class=\"main\" align=\"center\">". tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_template_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART));
      }
      else {
 echo (" <td class=\"main\" align=\"right\">".NON_ONLINE_ITEM);
      }  
      ?></form></td>
             <form name="wishlist_quantity" method="post" action="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_wishlist', 'NONSSL'); ?>">
              <td align="center" class="main">
                         <input type="hidden" name="products_id" value="<?php echo $product_info['products_id']; ?>">
                         <input type="hidden" name="products_model" value="<?php echo $product_info['products_model']; ?>">
                         <input type="hidden" name="products_name" value="<?php echo htmlspecialchars($product_info['products_name']); ?>">
                         <input type="hidden" name="products_price" value="<?php echo $product_info['products_price']; ?>">
                         <input type="hidden" name="final_price" value="<?php echo $product_info['final_price']; ?>">
                         <input type="hidden" name="products_tax" value="<?php echo $product_info['products_tax']; ?>">
<?php  
 $wishlist_id_query = tep_db_query('select products_id as wPID from ' . TABLE_WISHLIST . ' where products_id= ' . $product_info['products_id'] . ' and customers_id = ' . (int)$customer_id . ' order by products_name');
$wishlist_Pid = tep_db_fetch_array($wishlist_id_query);
if ( (!tep_not_null($wishlist_Pid[wPID])) && (tep_session_is_registered('customer_id')) && (!in_array($product_info['manufacturers_id'],$nononline_items)) )  echo tep_template_image_submit('button_add_wishlist.gif', IMAGE_BUTTON_ADD_WISHLIST); ?>
                       </td></form>
              <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
</table>

<?php
}
}
?>

           </td>

 

Carlos

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...