Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Displaying cutom classes


jbrevell

Recommended Posts

Using Cord Focke's Warengruppe contribution I've created a new table of custom classes for products (which are referenced by a new field product_class_id in table PRODUCTS)

 

I would like to display this class on the products.php description page. My PHP only extends to selecting from 1 table so I can display the product_class_id, but I'd like the user-friendly text!... could anyone help?

 

Thanks guys

 

John

Link to comment
Share on other sites

OK got the fix from the man himself:

 

I think what you need is a join with the table TABLE_PRODUCTS_CLASS like

this:

 

(i marked the new code with ***(new code)***

 

$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,

 

***pc.products_class_title***

 

from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd

 

***, " . TABLE_PRODUCTS_CLASS . " pc***

 

where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id

 

*** and p.products_class_id = pc.products_class_id***

 

and pd.language_id = '" . (int)$languages_id . "'");

 

(didnt tried out, but should work)

 

Now you should be able to display the name of the products_class:

 

echo $product_info['products_class_title'];

 

 

 

 

This worked fine when:

 

Had to add define('TABLE_PRODUCTS_CLASS', 'products_class'); to /includes/database_tables.php

 

Nothing then displayed as the first products_class_id in products_class was 1, where most of the sample products was 0. inserted another row in products_class with products_class_id = 0 etc. and it worked perfectly!

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...