[MOD] Show product Out of Stock on product category page

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
bart
Posts: 57
Joined: Wed Sep 08, 2010 5:40 pm
Location: UK

[MOD] Show product Out of Stock on product category page

Post by bart »

When you are on the category page with a list of products it isn't obvious that a product is out of stock. This code will display Out Of Stock in place of the 'Add To Cart' or 'Choose Options' links.
Capture.JPG
Open lib\templates\products_panel.php

find:

Code: Select all

if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
            $GLOBALS['HideActionAdd'] = '';
        } else {
            $GLOBALS['HideActionAdd'] = 'none';
        }
replace with:

Code: Select all

if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
            $GLOBALS['HideActionAdd'] = '';
            $GLOBALS['HideNoStock'] = 'none';
        } else {
            $GLOBALS['HideActionAdd'] = 'none';
            $GLOBALS['HideNoStock'] = '';
        }
Open templates\TEMPLATE\Snippets\CategoryProductsItem.html

Find:

Code: Select all

<div class="ProductActionAdd" style="display:%%GLOBAL_HideActionAdd%%;">
%%GLOBAL_ProductURL%%
</div>

Replace with:

Code: Select all

<div class="ProductActionAdd" style="display:%%GLOBAL_HideActionAdd%%;">
%%GLOBAL_ProductURL%%
</div>
<div class="ProductNoStock" style="display:%%GLOBAL_HideNoStock%%;">
Out of Stock
</div>
Extra template files can be changed for products in best sellers, featured product lists etc. Just repeat above step for relevant templates.
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [MOD] Show product Out of Stock on product category page

Post by Martin »

I went one stage further with a mod I did but obviously didn't share (well I can't remember)...

I put in a link to a KB article I keep up to date with any out of stock messages about when it's expected to be back in stock, etc...

Makes quite a difference.. I'll locate and post up the differences for those who want that functionality... probably over weekend.
xiangzhuang
Posts: 26
Joined: Sat May 28, 2011 9:23 pm

Re: [MOD] Show product Out of Stock on product category page

Post by xiangzhuang »

Image

is there any way i can add a .gif transparent layer on top of the image when its out of stock?
ISC 6.1.1 Linux
bart
Posts: 57
Joined: Wed Sep 08, 2010 5:40 pm
Location: UK

Re: [MOD] Show product Out of Stock on product category page

Post by bart »

I have used a 100px x 100px png with a transparent background. You will need to make this the same size as your thumbnails.

Open templates\TEMPLATE\Snippets\CategoryProductsItem.html

below

Code: Select all

<div class="ProductImage">
add:

Code: Select all

<div class="OutImage" style="display:%%GLOBAL_OutImage%%;"><img src="%%GLOBAL_IMG_PATH%%/nostock.png"></div>
You will need to put your image, here with the name nostock.png, in your current templates images folder.

Then find:

Code: Select all

<div class="ProductActionAdd" style="display:%%GLOBAL_HideActionAdd%%;">
%%GLOBAL_ProductURL%%
</div>
Replace with:

Code: Select all

<div class="ProductActionAdd" style="display:%%GLOBAL_HideActionAdd%%;">
%%GLOBAL_ProductURL%%
</div>
<div class="ProductNoStock" style="display:%%GLOBAL_HideNoStock%%;">
Out of Stock
</div>
To your style sheet add

Code: Select all

.OutImage {position:absolute; }
Open lib\templates\products_panel.php

find:

Code: Select all

if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
            $GLOBALS['HideActionAdd'] = '';
        } else {
            $GLOBALS['HideActionAdd'] = 'none';
        }
replace with:

Code: Select all

if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
			$GLOBALS['HideActionAdd'] = '';
			$GLOBALS['HideNoStock'] = 'none';
			$GLOBALS['OutImage'] = 'none';
		} else {
			$GLOBALS['HideActionAdd'] = 'none';
			$GLOBALS['HideNoStock'] = '';
			$GLOBALS['OutImage'] = '';
		}
Attachments
Capture.JPG
nostock.png
nostock.png (613 Bytes) Viewed 35591 times
xiangzhuang
Posts: 26
Joined: Sat May 28, 2011 9:23 pm

Re: [MOD] Show product Out of Stock on product category page

Post by xiangzhuang »

I have a problem,
Open templates\TEMPLATE\Snippets\CategoryProductsItem.html
I dont have any files in my template snippets folder
ISC 6.1.1 Linux
xiangzhuang
Posts: 26
Joined: Sat May 28, 2011 9:23 pm

Re: [MOD] Show product Out of Stock on product category page

Post by xiangzhuang »

I have the "login to see price" hack added so whenever I add this hack, all my products would be out of stock.
ISC 6.1.1 Linux
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [MOD] Show product Out of Stock on product category page

Post by Martin »

xiangzhuang wrote:I have a problem,
Open templates\TEMPLATE\Snippets\CategoryProductsItem.html
I dont have any files in my template snippets folder
That's because your theme is using the master template set...

If you get a copy of the \templates\__master\Snippets\CategoryProductsItem.html file and copy it to your templates\TEMPLATE\Snippets\ folder then edit it.

Any files in the templates folder for your chosen theme override those in the__master set which is why this approach works :)
xiangzhuang
Posts: 26
Joined: Sat May 28, 2011 9:23 pm

Re: [MOD] Show product Out of Stock on product category page

Post by xiangzhuang »

Oh ok thanks martin. I have another probem though, every time I insert the code, all my products would go out of stock for some reason.
ISC 6.1.1 Linux
bart
Posts: 57
Joined: Wed Sep 08, 2010 5:40 pm
Location: UK

Re: [MOD] Show product Out of Stock on product category page

Post by bart »

What is the URL of your website, i'll have a look at the code.
xiangzhuang
Posts: 26
Joined: Sat May 28, 2011 9:23 pm

Re: [MOD] Show product Out of Stock on product category page

Post by xiangzhuang »

The URL of my site is kwjewelry.co
ISC 6.1.1 Linux
Post Reply