Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hide Weight When the Value is Zero


Guest

Recommended Posts

Hi there i was hoping to find out a way to hide the weight of my product when the value is zero... The was my site is set up it shows the product image, model and weight when you click on a subcategory. I have many products where i want to show the weight but ones where i do not want it to be shown so how can i set it up that on the subcategory page where all my products are listed products with a weight of zero have the weight hidden so it only shows the product image, model and thats it. the link for this type of page comes up as this /index.php/hallway-coat-stands-c-65_121. I am running 2.3.1 many thanks in advance.

Link to comment
Share on other sites

In includes/modules/product_listing.php (may be at lines 124-126) find

	 case 'PRODUCT_LIST_WEIGHT':
	 $prod_list_contents .= '	 <td align="right">' . $listing['products_weight'] . '</td>';
	 break;

and replace it with something like

	 case 'PRODUCT_LIST_WEIGHT':
	 $prod_list_contents .= '	 <td align="right">' . (($listing['products_weight'] > 0) ? $listing['products_weight'] : ' ') . '</td>';
	 break;

You can replace the   with text if you want, but you'll want to be careful about translation issues. Some browsers may cause problems if you leave the cell entirely empty, so be sure to place something there.

Always back up before making changes.

Link to comment
Share on other sites

@@ecartz hi there i have done this however it only hides the actual weight not the piece of text saying weight. How would i hide both of them as i just want the text saying "Weight:" and the actual number gone when the eight value is zero? many thanks for all you help it is so apprectiated.

Link to comment
Share on other sites

You want to hide the Weight column when the weight is zero for all the items in the column? There's not going to be a simple way to do that. The problem is that you display the column headers before you fetch the rows.

 

If you are not using the normal product listing table where each row is a product, then you'll have to post your code.

Always back up before making changes.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...