Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi all,

 

i have searched methodically on here for a solution to no avail.

 

i am using the featured products contrib which is working perfectly (found here: http://addons.oscommerce.com/info/4491)

 

however, i would like to tweak it slightly so it pulls in the manufacturers image (with a link to the manufacturers other products if you click the image)

 

i have tried everything i can think of to get this to work, to no avail

 

can anyone assist please?

 

any help would be HUGELY appreciated!

 

regards

 

YT

 

if it helps my featured code is as follows:

 

<!-- featured_products //-->
<?php
if(FEATURED_PRODUCTS_DISPLAY == 'true')
{
 $featured_products_category_id = $new_products_category_id;
 $cat_name_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $featured_products_category_id . "' limit 1");
 $cat_name_fetch = tep_db_fetch_array($cat_name_query);
 $cat_name = $cat_name_fetch['categories_name'];
 $info_box_contents = array();

 if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) {
$info_box_contents[] = array('align' => 'left', 'text' => '<a class="headerNavigation" href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a>');

 list($usec, $sec) = explode(' ', microtime());
 srand( (float) $sec + ((float) $usec * 100000) );
 $mtm= rand();

$featured_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand($mtm) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 } else {
$info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
$featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 }

 $row = 0;
 $col = 0; 
 $num = 0;
 while ($featured_products = tep_db_fetch_array($featured_products_query)) {
$num ++; if ($num == 1) { // new contentBoxHeading($info_box_contents); 
}
$featured_products['products_name'] = tep_get_products_name($featured_products['products_id']);
if($featured_products['specstat']) {

$sql = 'SELECT `products_description` FROM `products_description` WHERE products_id ='.$featured_products['products_id'].' && language_id='.(int)$languages_id;
$description_query = tep_db_query($sql);
$description = mysql_fetch_array($description_query, MYSQL_ASSOC);		
$description['products_description'] = substr($description['products_description'], 0, 150);
$desc_len = strlen($description['products_description']);
$description['products_description'][$desc_len-1] = '.';
$description['products_description'][$desc_len-2] = '.';
$description['products_description'][$desc_len-3] = '.';

$description['products_description'] = ereg_replace("(Array)", "", $description['products_description']);

  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" cellspacing="0" width="33%" valign="top"',
									   'text' => '<table width="100%" border="0" cellspacing="0" bgcolor="#ffffff" cellpadding="0">
 <tr>
<td align="right" valign="bottom" bordercolor="0"><img src="images/infobox/upper_left.gif" alt="1" width="12" height="33" /></td>	
<td colspan="2" background="images/infobox/top.gif" class=mws_boxTop><a class=productTitle href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . substr($featured_products['products_name'], 0, 30) . '</a></td>
<td align="left" valign="bottom"><img src="images/infobox/upper_right.gif" alt="2" width="14" height="33" /></td>
 </tr>
 <tr>
<td background="images/infobox/left.gif"> </td>
<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br> <a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS). '">' . tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/featured.gif', IMAGE_FEATUREDPRODUCT). '</a> </td>
<td class="smallText">'. strip_tags($description['products_description']) . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $featured_products["products_id"]). '">' . DESCR_READ_MORE . '</a><br><br><s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id']) . '">' . tep_image_button('cart_buy.gif', IMAGE_BUTTON_IN_CART) . '</a> <span class="productSpecialPrice">' . $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span></td>
<td background="images/infobox/right.gif" class="smallText"><img src="images/infobox/right.gif" width="14" height="149" /></td>
 </tr>
 <tr>
<td align="right" valign="top"><img src="images/infobox/lower_left.gif" alt="5" width="12" height="12" /></td>
<td colspan="2" background="images/infobox/bot.gif"><img src="images/infobox/bot.gif" alt="5" width="2" height="12" /></td>
<td align="left" valign="top" class="smallText"><img src="images/infobox/lower_right.gif" alt="2" width="14" height="12" /></td>
 </tr>
</table>');
} else {

$sql = 'SELECT `products_description` FROM `products_description` WHERE products_id ='.$featured_products['products_id'].' && language_id='.(int)$languages_id;
$description_query = tep_db_query($sql);
$description = mysql_fetch_array($description_query, MYSQL_ASSOC);		
$description['products_description'] = substr($description['products_description'], 0, 150);
$desc_len = strlen($description['products_description']);
$description['products_description'][$desc_len-1] = '.';
$description['products_description'][$desc_len-2] = '.';
$description['products_description'][$desc_len-3] = '.';

$description['products_description'] = ereg_replace("(Array)", "", $description['products_description']);

  $info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" cellspacing="0" width="33%" valign="top"',
									   'text' => '<table width="100%" border="0" cellspacing="0" bgcolor="#ffffff" cellpadding="0">
 <tr>
<td align="right" valign="bottom" bordercolor="0"><img src="images/infobox/upper_left.gif" alt="1" width="12" height="33" /></td>	
<td colspan="2" background="images/infobox/top.gif" class=mws_boxTop><a class=productTitle href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . substr($featured_products['products_name'], 0, 30) . '</a></td>
<td align="left" valign="bottom"><img src="images/infobox/upper_right.gif" alt="2" width="14" height="33" /></td>
 </tr>
 <tr>
<td background="images/infobox/left.gif"> </td>
<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_EXT_HTTP . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br> <a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS). '">' . tep_image(DIR_WS_IMAGES . '/buttons/featured.gif', IMAGE_FEATUREDPRODUCT). '</a> </td>
<td class="smallText">'. strip_tags($description['products_description']) . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $featured_products["products_id"]). '">' . DESCR_READ_MORE . '</a><br><br><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id']) . '">' . tep_image_button('cart_buy.gif', IMAGE_BUTTON_IN_CART) . '</a> ' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . ' </td>
<td background="images/infobox/right.gif" class="smallText"><img src="images/infobox/right.gif" width="14" height="100" /></td>
 </tr>
 <tr>
<td align="right" valign="top"><img src="images/infobox/lower_left.gif" alt="5" width="12" height="12" /></td>
<td colspan="2" background="images/infobox/bot.gif"><img src="images/infobox/bot.gif" alt="5" width="2" height="12" /></td>
<td align="left" valign="top" class="smallText"><img src="images/infobox/lower_right.gif" alt="2" width="14" height="12" /></td>
 </tr>
</table>');
}	
$col ++;
if ($col > 1) {
  $col = 0;
  $row ++;
}
 }
 if($num) {

  new noborderbox($info_box_contents);
 }
} else // If it's disabled, then include the original New Products box
{
  include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS);
}
?><!-- featured_products_eof //-->

there are 10 types of people who understand binary

 

those that do, and those that don't

Posted (edited)

include manufacturers_id in the sql query like so..

 

	$featured_products_query = tep_db_query("select p.manufacturers_id p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand($mtm) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 } else {
$info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
$featured_products_query = tep_db_query("select distinct p.manufacturers_id, p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 }

 

and before both instances of

 

$sql = 'SELECT `products_description` FROM `products_description` WHERE products_id ='.$featured_products['products_id'].' && language_id='.(int)$languages_id;

 

add

 

$mansql = "select manufacturers_image from manufacturers where manufacturers_id = $featured_products['manufacturers_id']";
 $manresult = mysql_query($mansql)
or die(mysql_error()); 
$man = mysql_fetch_array($manresult);

 

then in both tables place the code to grab the image wherever you like something along these lines

 

<a href="index.php?manufacturers_id=' . $featured_products['manufacturers_id']. '"><img src="images/'.$man['manufacturers_image'].'"/></a>

Edited by Jonojamesmac
Posted
include manufacturers_id in the sql query like so..

 

	$featured_products_query = tep_db_query("select p.manufacturers_id p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand($mtm) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 } else {
$info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
$featured_products_query = tep_db_query("select distinct p.manufacturers_id, p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 }

 

and before both instances of

 

$sql = 'SELECT `products_description` FROM `products_description` WHERE products_id ='.$featured_products['products_id'].' && language_id='.(int)$languages_id;

 

add

 

$mansql = "select manufacturers_image from manufacturers where manufacturers_id = $featured_products['manufacturers_id']";
 $manresult = mysql_query($mansql)
or die(mysql_error()); 
$man = mysql_fetch_array($manresult);

 

then in both tables place the code to grab the image wherever you like something along these lines

 

<a href="index.php?manufacturers_id=' . $featured_products['manufacturers_id']. '"><img src="images/'.$man['manufacturers_image'].'"/></a>

 

Huge thanks for the effort you put in so far ;)

 

i now get this error:

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /includes/modules/featured.php on line 48

 

line 48 relates to:

$mansql = "select manufacturers_image from manufacturers where manufacturers_id = $featured_products['manufacturers_id']";
 $manresult = mysql_query($mansql)
or die(mysql_error()); 
$man = mysql_fetch_array($manresult);

 

hope that helps?

 

regards and HUGE thanks

 

YT

there are 10 types of people who understand binary

 

those that do, and those that don't

Posted

oops was late last night :P

 

$mansql = "select manufacturers_image from manufacturers where manufacturers_id = $featured_products['manufacturers_id']";

 

change to

 

$mansql = "select manufacturers_image from manufacturers where manufacturers_id = '" . $featured_products['manufacturers_id']."'";

Posted (edited)
oops was late last night :P

 

$mansql = "select manufacturers_image from manufacturers where manufacturers_id = $featured_products['manufacturers_id']";

 

change to

 

$mansql = "select manufacturers_image from manufacturers where manufacturers_id = '" . $featured_products['manufacturers_id']."'";

 

Jono,

 

have edited as you said, however i know get this error:

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s' at line 1

 

select p.manufacturers_id p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from products p left join specials s on p.products_id = s.products_id left join featured f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand(489643102) DESC limit 6

 

[TEP STOP]

 

you help is appreciated!

 

regards

 

YT

Edited by yt_boy

there are 10 types of people who understand binary

 

those that do, and those that don't

Posted
Your missing a comma after p.manufacturers_id

 

My fault though as i missed it out initially :)

 

 

YOU ARE A GOD!!!

 

huge thanks dude!

 

regards

 

YT

there are 10 types of people who understand binary

 

those that do, and those that don't

Posted

Jono,

 

how would i use the call up in the follwing code?

 

<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_EXT_HTTP . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br> <a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS). '">' . tep_image(DIR_WS_IMAGES . '/buttons/featured.gif', IMAGE_FEATUREDPRODUCT). '</a> </td>
<td class="smallText">'. strip_tags($description['products_description']) . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $featured_products["products_id"]). '">' . DESCR_READ_MORE . '</a><br><br><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id']) . '">' . tep_image_button('cart_buy.gif', IMAGE_BUTTON_IN_CART) . '</a> ' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . ' </td>
<td background="images/infobox/right.gif" class="smallText"><img src="images/infobox/right.gif" width="14" height="100" /></td>

 

ideally using tep_href_link(FILENAME_DEFAULT, for the image link and tep_image(DIR_EXT_HTTP for the image aligning it to the right of the price?

 

advice would be appreciated

 

regards

 

YT

there are 10 types of people who understand binary

 

those that do, and those that don't

Posted

<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_EXT_HTTP . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br> <a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS). '">' . tep_image(DIR_WS_IMAGES . '/buttons/featured.gif', IMAGE_FEATUREDPRODUCT). '</a> </td>
<td class="smallText">'. strip_tags($description['products_description']) . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $featured_products["products_id"]). '">' . DESCR_READ_MORE . '</a><br><br><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id']) . '">' . tep_image_button('cart_buy.gif', IMAGE_BUTTON_IN_CART) . '</a> ' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $featured_products['manufacturers_id']) . '">' . tep_image(DIR_EXT_HTTP . $man['manufacturers_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>
<td background="images/infobox/right.gif" class="smallText"><img src="images/infobox/right.gif" width="14" height="100" /></td>

 

Try this...

Posted
<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_EXT_HTTP . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br> <a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS). '">' . tep_image(DIR_WS_IMAGES . '/buttons/featured.gif', IMAGE_FEATUREDPRODUCT). '</a> </td>
<td class="smallText">'. strip_tags($description['products_description']) . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $featured_products["products_id"]). '">' . DESCR_READ_MORE . '</a><br><br><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products['products_id']) . '">' . tep_image_button('cart_buy.gif', IMAGE_BUTTON_IN_CART) . '</a> ' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $featured_products['manufacturers_id']) . '">' . tep_image(DIR_EXT_HTTP . $man['manufacturers_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>
<td background="images/infobox/right.gif" class="smallText"><img src="images/infobox/right.gif" width="14" height="100" /></td>

 

Try this...

 

 

worked nearly spot on mate thanks

 

however when i hover over the image it says 100 not the manu name, i have managed to add the manufacturers_name to Smansql with no probs, but cant see where to include in code to do this (without affecting the small image width command

 

last time i bug you - promise!

 

regards

 

YT aka Keith

there are 10 types of people who understand binary

 

those that do, and those that don't

Posted

change

tep_image(DIR_EXT_HTTP . $man['manufacturers_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)

to this

tep_image(DIR_EXT_HTTP . $man['manufacturers_image'], $man['manufacturers_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)

Posted
change

tep_image(DIR_EXT_HTTP . $man['manufacturers_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)

to this

tep_image(DIR_EXT_HTTP . $man['manufacturers_image'], $man['manufacturers_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)

 

spot on buddy

 

like a charm!

 

huge thanks!

 

regards

 

YT

there are 10 types of people who understand binary

 

those that do, and those that don't

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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