Adding product availability to pages_default.tpl

Silencer116

Avatar: Silencer116

2011-04-14 12:54

Hi there,

My client wants to show the product availability in the list of products in the sub-pages and result page.
Now I managed to place the product availability with the $aData[sAvailable] tag, but this only shows what the user has inserted in the admin.

I want to make this dynamic because I wish to add an icon to each particular description. For example, when the user inserts "Op voorraad" in admin, the front should show a particular icon.

What I did now, is I inserted a img tag in admin, but obviously, this is not the best solution. I want to create a function or method that changes the output depending on the input.

I hope you can understand what I want to achieve.

Can someone help me on this? Thanks in advance.

» Quick.Cart v3.x

Silencer116

Avatar: Silencer116

2011-04-14 12:56

Update;

I managed to paste the $aData[aAvailable] tag into pages_defailt.tpl, but I can't use php to check the value. I wish to check the value, so I can decide what icon I want to add to it.

Makaron

Avatar: Makaron

2011-04-14 15:41

First try to edit file lang/en.php (or language file which You using) and add as many variables as You need fe.

$lang['AvailableOption1'] = 'Option 1 text';
$lang['AvailableOption2'] = 'Option 2 text';
$lang['AvailableOption3'] = 'Option 3 text';



After that You can edit file core/products.php function listProducts() and in this function You can add if statement for example:

if( isset( $aData['sAvailable'] ) && !empty( $aData['sAvailable'] ) ){
    if( 
strcmptrim$aData['sAvailable'] ), trim$GLOBALS['lang']['AvailableOption1'] ) ) == )
        
$aData['sAvailableIcon'] = '<img src="path_to_icon/icon.jpg" alt="" />';
}



In file templates/pages_default.tpl in block PRODUCTS_LIST You can add variable $aData[sAvailableIcon]

Most important is statement in listProducts() function. It means if You set product's availablity to the same value which is in variable $lang['AvailableOption1'] script will add image code:

<img src="path_to_icon/icon.jpg" alt="" />


of course You have to change path and name of image. Is it clear for You?

I helped? Like it: www.facebook.com/makwebpl

Silencer116

Avatar: Silencer116

2011-05-12 00:20

Thank you so much for your answer.

But It seems not to work; I get the feeling that the variable $aData[sAvailableIcon] is not passed on to the products page.

Do I need to set this variable first??

Makaron

Avatar: Makaron

2011-05-12 16:57

No You don't have to. Where You put code which I gave You?

I helped? Like it: www.facebook.com/makwebpl

Silencer116

Avatar: Silencer116

2011-05-14 15:12

I posted this statement at the bottom inside the function listProducts() in core/products.php

if( isset( $aData['sAvailable'] ) && !empty( $aData['sAvailable'] ) ){
    if( 
strcmptrim$aData['sAvailable'] ), trim$GLOBALS['lang']['AvailableOption1'] ) ) == )
        
$aData['sAvailableIcon'] = '<img src="path_to_icon/icon.jpg" alt="" />';
}



perhaps I posted it at the wrong place?

Makaron

Avatar: Makaron

2011-05-16 16:20

Try to add this code after line:

$aData['sPages'] = $this->throwProductsPagesTree$aData['iProduct'] );

I helped? Like it: www.facebook.com/makwebpl

Silencer116

Avatar: Silencer116

2011-05-17 12:00

It works!

Thank you so much! This is great!

Back to top
about us | contact