Page 1 of 2
[MOD] Show product Out of Stock on product category page
Posted: Fri May 27, 2011 1:07 pm
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.
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.
Re: [MOD] Show product Out of Stock on product category page
Posted: Fri May 27, 2011 4:39 pm
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.
Re: [MOD] Show product Out of Stock on product category page
Posted: Wed Jul 06, 2011 10:51 pm
by xiangzhuang
is there any way i can add a .gif transparent layer on top of the image when its out of stock?
Re: [MOD] Show product Out of Stock on product category page
Posted: Thu Jul 07, 2011 3:12 pm
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
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
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'] = '';
}
Re: [MOD] Show product Out of Stock on product category page
Posted: Sat Jul 09, 2011 3:34 pm
by xiangzhuang
I have a problem,
Open templates\TEMPLATE\Snippets\CategoryProductsItem.html
I dont have any files in my template snippets folder
Re: [MOD] Show product Out of Stock on product category page
Posted: Sat Jul 09, 2011 5:57 pm
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.
Re: [MOD] Show product Out of Stock on product category page
Posted: Mon Jul 11, 2011 9:25 am
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

Re: [MOD] Show product Out of Stock on product category page
Posted: Wed Jul 13, 2011 3:22 pm
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.
Re: [MOD] Show product Out of Stock on product category page
Posted: Mon Jul 18, 2011 1:01 pm
by bart
What is the URL of your website, i'll have a look at the code.
Re: [MOD] Show product Out of Stock on product category page
Posted: Sun Jul 24, 2011 4:16 pm
by xiangzhuang
The URL of my site is kwjewelry.co