Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

HELP: How to display category in the product info?


t000

Recommended Posts

Hi every one, at the topic states i need help to add the current category group to the selected product info page. 

I want the category to be displayed under the product name. Im talking about the ´last´ product info page (../product_info.php?products_id=594).

Ive been playing around in product_info.php. But I can only the . $product_info['products_image'] to display, manufacture_id also work. 

 

<?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);

    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 = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <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'] . '] <br>  ' . $product_info['products_image'] . '  </span>';  

    } else {
      $products_name = $product_info['products_name'] ; 
    }
?>

 

 

Link to comment
Share on other sites

I'm using this database configuration:

Table: products 
Edit product -> ibm1961
products_image | varchar(64) | Value: images/computers/ibm1961.jpg 
- MySQL Client API version 5.5.55 / Client API header version 5.5.46

When requesting data with $product_info['products_image'], I get this value images/computers/ibm1961.jpg.

How can I only grab the middle part of the value, so that I get computers?

Link to comment
Share on other sites

@wHiTeHaT

Maby you can answer this also?

Im trying in the same place to display the manufacture name. What am I doing wrong?

<?php 
$manufacturers_01 = $manufacturers['manufacturers_name'];
echo $manufacturers_01; 
?>

The database is called, as you probably know: manufacturers -> manufacturers_name | varchar(32) | Value: XXX

Yes im a novice, but im trying my best to learn ;) 

Link to comment
Share on other sites

That part is/should already be covered in the product_info.php file if use the osCommerce bs community version.
 

    if ($product_info['manufacturers_id'] > 0) {
      $manufacturer_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$product_info['manufacturers_id'] . "'");
      if (tep_db_num_rows($manufacturer_query)) {
        $manufacturer = tep_db_fetch_array($manufacturer_query);
        echo '<span itemprop="manufacturer" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="' . tep_output_string($manufacturer['manufacturers_name']) . '" /></span>';
      }
    }

 

Link to comment
Share on other sites

7 minutes ago, wHiTeHaT said:

That part is/should already be covered in the product_info.php file if use the osCommerce bs community version.
 


    if ($product_info['manufacturers_id'] > 0) {
      $manufacturer_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$product_info['manufacturers_id'] . "'");
      if (tep_db_num_rows($manufacturer_query)) {
        $manufacturer = tep_db_fetch_array($manufacturer_query);
        echo '<span itemprop="manufacturer" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="' . tep_output_string($manufacturer['manufacturers_name']) . '" /></span>';
      }
    }

 

Hmm.. strange. Ive been serching the product_info.php for days, havent found any callouts for the manufacturers_id. Im using the standard osCommerce Online Merchant v2.3.4 with no themes.

Anyway, I tried your script @wHiTeHaT, but i couldnt get it to work :( Nothing is showing up.

Link to comment
Share on other sites

Correction, here is the code that worked for me! Thanks again @wHiTeHaT! All creds to you pal!

<?
  if ($product_info['manufacturers_id'] > 0) {
      $manufacturer_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$product_info['manufacturers_id'] . "'");
      if (tep_db_num_rows($manufacturer_query)) {
        $manufacturer = tep_db_fetch_array($manufacturer_query);
echo '' . tep_output_string($manufacturer['manufacturers_name']) . '';
      }
    }
?>

 

Link to comment
Share on other sites

Hi Tom, You are very diligent in try understanding coding.

But i must say also that your question is related to the basics of programming, giving you the answer will not help you in future questions or learning.

I would like to encourage you to learn a little more so you understand the global principe of that.

the code above works perfectly as you found already out via the pagesource.

Now be a little more clever, you already know how to directly show something on your screen, use the same principle for the code i provided to get something to show up.

I am 100% when you figure that out, more things will getting clear for you.

Link to comment
Share on other sites

product_info.php, look into these two variables;

For category:  $current_category_id

For manufacturer:  $product_info['manufacturers_id']

With these two variables you can easily get info from the DB as needed.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...