Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding product description to "What's New"


Styles

Recommended Posts

Does anyone have any idea how to call the product description for the item profiled in the "What's New" box? I'm assuming it would be based off another query using the product ID from the first, but I can't seem to get it to work.

 

I'm not using a modified "whats_new.php" so anybody's version should work if you are going to attempt to figure it out.

 

Any help is much appreciated,

 

Thanks.

Link to comment
Share on other sites

If your product descriptions are not really long then you should be able to just add the product_description field to your SQL query then display it where you want. There is a contribution which does this for product listing, so maybe have a look at that and see if it helps.

Link to comment
Share on other sites

If your product descriptions are not really long then you should be able to just add the product_description field to your SQL query then display it where you want. There is a contribution which does this for product listing, so maybe have a look at that and see if it helps.

 

Thanks Mike. I tried to add that field to the query but then realized that field wasn't part of the table being queried. It's looking at the "product" table, rather than the "product_description" table.

 

I'm sure it's not rocket-science, but I'm still an amateur PHP user and parts of this is over my head.

Link to comment
Share on other sites

shout be pretty easy to change the query to pull the description.

 

In the select clause add ...

 

pd.products_description

 

In the from clause add...

 

prodcut_description pd

 

In the where clause add..

 

and p.products_id = pd.products_id

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

Add the table to the query, or post your sql query here and ill try and do something for you l8r

 

Thanks guys. Here is my SQL query so you can have a look:

 

if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

 

I would like to show the manufacturer too, but I'm sure I can figure it out if you show me how to do this one. Thanks very much.

Link to comment
Share on other sites

if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

 

Like Chris says, it would be something like this..

 

if ($random_product = tep_random_select("select pd.products_description, products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . TABLE_PRODUCTS_DESCRIPTION . " pd, " where products_status = '1' and products_id = pd.products_id order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW))

 

I am no expert but i think the above will work, Chris would be able to confirm if this is correct.

 

Next thing would be to echo the products description where you want.

 

Hope that helps

 

Cheers

Link to comment
Share on other sites

if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

 

Like Chris says, it would be something like this..

 

if ($random_product = tep_random_select("select pd.products_description, products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . TABLE_PRODUCTS_DESCRIPTION . " pd, " where products_status = '1' and products_id = pd.products_id order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW))

 

I am no expert but i think the above will work, Chris would be able to confirm if this is correct.

 

Next thing would be to echo the products description where you want.

 

Hope that helps

 

Cheers

 

Thanks Mike. I received a "Parse error: parse error, unexpected T_STRING", but I think that it's very close. I'll play around with it and hopefully you or Chris will have some more insight soon. Thanks again.

Link to comment
Share on other sites

if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

 

Like Chris says, it would be something like this..

 

if ($random_product = tep_random_select("select pd.products_description, products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . TABLE_PRODUCTS_DESCRIPTION . " pd, " where products_status = '1' and products_id = pd.products_id order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW))

 

I am no expert but i think the above will work, Chris would be able to confirm if this is correct.

 

Next thing would be to echo the products description where you want.

 

Hope that helps

 

Cheers

 

Thanks Mike. I received a "Parse error: parse error, unexpected T_STRING", but I think that it's very close. I'll play around with it and hopefully you or Chris will have some more insight soon. Thanks again.

Link to comment
Share on other sites

if ($random_product = tep_random_select("select pd.products_description, products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . TABLE_PRODUCTS_DESCRIPTION . " pd, " where products_status = '1' and products_id = pd.products_id order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

 

 

sry i think i missed out the opening bracket at the end so if you just copied my code over yours maybe thats it

Link to comment
Share on other sites

if ($random_product = tep_random_select("select pd.products_description, products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . TABLE_PRODUCTS_DESCRIPTION . " pd, " where products_status = '1' and products_id = pd.products_id order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

sry i think i missed out the opening bracket at the end so if you just copied my code over yours maybe thats it

 

I think the problem is actually where it says ... "pd, " where... In my syntax checker, that's where the code seems to go funny. Is that the correct code there?

Link to comment
Share on other sites

if ($random_product = tep_random_select('SELECT PD.products_description, P.products_id, P.products_image, P.products_tax_class_id, P.products_price FROM ' . TABLE_PRODUCTS . ' P INNER JOIN ' . TABLE_PRODUCTS_DESCRIPTION .' PD ON P.products_id=PD.products_id WHERE P.products_status=1 ORDER BY P.products_date_added DESC LIMIT ' . MAX_RANDOM_SELECT_NEW)) {

Link to comment
Share on other sites

if ($random_product = tep_random_select('SELECT PD.products_description, P.products_id, P.products_image, P.products_tax_class_id, P.products_price FROM ' . TABLE_PRODUCTS . ' P INNER JOIN ' . TABLE_PRODUCTS_DESCRIPTION .' PD ON P.products_id=PD.products_id WHERE P.products_status=1 ORDER BY P.products_date_added DESC LIMIT ' . MAX_RANDOM_SELECT_NEW)) {

 

Awesome, the query works like a charm. Now I just have to figure out how to call what has been queried... doesn't seem to want to cooperate.

 

Thanks a lot!

Link to comment
Share on other sites

One problem I'm experiencing with this is that the description seems to arbitrarily decide when to show up. If I keep refreshing, sometimes the description is there, and other times it isn't. Does anyone know why this is happening, judging from that code?

 

Could it be the way I'm calling it?

 

<p>' . $random_product['products_description'] . '</p>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...