Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

QTY = 1, display message or image in catalog


jhande

Recommended Posts

What I am looking to do is when a products quantity reaches a set amount (say 1 in stock), that a message shows on the product info page and/or product listing page.

Something along these lines: Limited Supply or Discontinued

 

I thought I stumbled across something that might do just that a long time ago. But for the life of me I can't find anything now.

 

Any thoughts, ideas or pointing in the right direction would be greatly appreciated!

 

:huh:

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Well... getting it to work on the product_info.php was easier than I thought.

 

But I am not sure how to add it to the category/product listing (index.php). <_<

 

I would like it to display after the products name, but I'm not sure if I'm going about it correctly and how to merger two PHP codes.

 

This is what I have that works:

<?php

if($product_info['products_quantity'] = 1)

echo tep_image('images/discontinued.gif');

?>

I think this is the section of code where I need to add the changes:

$select_column_list = '';

 

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

switch ($column_list[$i]) {

case 'PRODUCT_LIST_MODEL':

$select_column_list .= 'p.products_model, ';

break;

case 'PRODUCT_LIST_NAME':

$select_column_list .= 'pd.products_name, ';

break;

case 'PRODUCT_LIST_MANUFACTURER':

$select_column_list .= 'm.manufacturers_name, ';

break;

 

If that's the correct place, how do I mix the code together correctly?

$select_column_list .= 'pd.products_name, ' if($product_info['products_quantity'] = 1)

echo tep_image('images/discontinued.gif');

 

The above isn't correct as I receive this error:

"Parse error: syntax error, unexpected T_IF in /home3/handesho/public_html/index.php on line 180"

 

 

:huh: :blush:

 

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

In index.php find each instance of

"select " . $select_column_list . " p.products_id,

change to

"select " . $select_column_list . "  p.products_quantity, p.products_id,

 

If you then want to display your image under the product name then edit includes/modules/product_listing.php

find:

		  case 'PRODUCT_LIST_NAME':
		$lc_align = '';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
		} else {
		  $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
		}
		break;

change to

		  case 'PRODUCT_LIST_NAME':
		$lc_align = '';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
		} else {
		  $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
		}
		if (1 == $listing[$x]['products_quantity']) {
		  $lc_text .= '<br>' . tep_image(DIR_WS_IMAGES . 'discontinued.gif');
	   }
		break;

Link to comment
Share on other sites

If you then want to display your image under the product name then edit includes/modules/product_listing.php

find: ...

change to

		  case 'PRODUCT_LIST_NAME':
		$lc_align = '';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
		} else {
		  $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
		}
		if (1 == $listing[$x]['products_quantity']) {
		  $lc_text .= '
' . tep_image(DIR_WS_IMAGES . 'discontinued.gif');
	   }
		break;

 

Thank you Tom!

 

I tried as you posted above but the image did not show. Maybe it is because of my slightly altered code as seen below?

case 'PRODUCT_LIST_NAME':
					  $lc_align = 'left';
	$lc_width = '*';
						if (isset($HTTP_GET_VARS['manufacturers_id'])) {
						$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '"><b>' . $listing['products_name'] . '</a></b>' . '
' . $listing['short_desc']; 
	   break;
			} else {
		   $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '"><b>' . $listing['products_name'] . '</a></b>' . '
' . $listing['short_desc'];
	   }
	   break;

 

If I can get it to work, I'd like to have the image to the right of the product name. Allowing the short description to be on the following line under the product name.

 

I tried playing with the code but each time something would break. I'd either lose the product name or I'd lose the short description.

 

:blush:

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

from your code try:

case 'PRODUCT_LIST_NAME':
 $lc_align = 'left';
 $lc_width = '*';
 if (isset($HTTP_GET_VARS['manufacturers_id'])) {
$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '"><b>' . $listing['products_name'] . '</a></b>';
  } else {
$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '"><b>' . $listing['products_name'] . '</a></b>';
 }
 if (1 == $listing['products_quantity']) {
$lc_text .= tep_image(DIR_WS_IMAGES . 'discontinued.gif');
 }
 $lc_text .= $listing['short_desc'];
  break;

Link to comment
Share on other sites

Thank you so much Tom ;)

 

I ended up with a bit of an alignment issue (some product names too long) so I swapped your code edits to the product model column and it works great.

 

All I have to do now is create either a graphic I am happy with or switch it to plain text.

 

Again, big thanks I truely appreciate the help! :)

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...