Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / How to ad css class to all sold out products on product listing

How to ad css class to all sold out products on product listing

21 Oct 2015, 3:02 PM
#1
perfumbg avatar

perfumbg

Zen Follower

Join Date:
May 2010
Posts:
192
Plugin Contributions:
5

Post #1 by perfumbg

Hello, i am wondering how to add css class to all products images that are sold out on product listing pages?
I want to make black/white all pictures of sold out products till they are again in stock.

Best regards and many thanks in advance.

My most recent work: magprom.net

22 Oct 2015, 3:46 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #2 by mc12345678

perfumbg:

Hello, i am wondering how to add css class to all products images that are sold out on product listing pages?
I want to make black/white all pictures of sold out products till they are again in stock.

Best regards and many thanks in advance.

Seems that basically will want to target the file: includes/modules/YOUR_TEMPLATE/product_listing.php

There is a while loop within that file and the variable $listing->fields['products_quantity'] represents the quantity of the product in question. From that point, would want to "properly" assign the start and end of your new class based on your setup and desired operation. As to having that apply only to the product listing and not say featured listing, or specials listing, then as part of the check would need to identify if the $page_name or other factors are set as desired... Even testing perhaps if $tpl_page_body == 'tpl_index_product_list.php' might be possible (value is assigned back in the main_template_vars.php file for includes/modules/pages/index when the page is presenting categories.) There are other ways to test/identify the current page and it all depends on how you want things to work. :)

By-the-way YOUR_TEMPLATE would be the template override folder that is named the same as where your template is installed in the path includes/templates/YOUR_TEMPLATE. If the file does not exist in that directory then copy the file of the same name from includes/modules to the template override (creating the directory if necessary) and then make the edits desired...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...