Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / traffic light stock level indicator

traffic light stock level indicator

Locked

Views: 8,691

Results 1 to 20 of 33
This thread is locked. New replies are disabled.
1 May 2007, 2:08 AM
#1
modchipfitters_co_uk avatar

modchipfitters_co_uk

Zen Follower

Join Date:
Sep 2006
Location:
United Kingdom
Posts:
190
Plugin Contributions:
0

traffic light stock level indicator

im trying to get my product stock levels to show up as traffic light system rather than a text number and i found this thread http://www.zen-cart.com/forum/showthread.php?t=12588&highlight=traffic+light

i followed what it said but i think there is a bit i missing somewhere because there is a link another thread on there that is now dead

i added the code showed in the thread but it didnt make any difference there was absolutly no change to the product page at all

can any help me please

4 May 2007, 2:20 AM
#2
modchipfitters_co_uk avatar

modchipfitters_co_uk

Zen Follower

Join Date:
Sep 2006
Location:
United Kingdom
Posts:
190
Plugin Contributions:
0

Re: traffic light stock level indicator

well been trying to get his working for a few days now and im getting no where
is there any one who can help point me in the right direction ppppllleeaaassee :D

4 May 2007, 2:23 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: traffic light stock level indicator

Have you an URL to the page where you want this to show?

4 May 2007, 2:35 AM
#4
modchipfitters_co_uk avatar

modchipfitters_co_uk

Zen Follower

Join Date:
Sep 2006
Location:
United Kingdom
Posts:
190
Plugin Contributions:
0

Re: traffic light stock level indicator

i want it to show up on eacvh product page in place of where it normally says "10 units instock" or how ever many just under where it says "Shipping Weight: 0.06KGs"
ill attach a screnn shot so that you get a better idea

4 May 2007, 3:00 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: traffic light stock level indicator

What code did you use to do this?

The code on the other link looks to be for the Product Listing and not the Product _info page ...

4 May 2007, 3:01 AM
#6
modchipfitters_co_uk avatar

modchipfitters_co_uk

Zen Follower

Join Date:
Sep 2006
Location:
United Kingdom
Posts:
190
Plugin Contributions:
0

Re: traffic light stock level indicator

i used the code from the link lol silly me

so is ther any way to get it to work on the product info page?

4 May 2007, 3:03 AM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: traffic light stock level indicator

Same concept but the products_id is based on (int)$_GET['products_id'] ... :smile:

4 May 2007, 3:05 AM
#8
modchipfitters_co_uk avatar

modchipfitters_co_uk

Zen Follower

Join Date:
Sep 2006
Location:
United Kingdom
Posts:
190
Plugin Contributions:
0

Re: traffic light stock level indicator

ok now you lost me lol
im not good with code
i can alter bits here and there but i get lost on anything complicated or anything with smarty tags lol:blush:

4 May 2007, 3:16 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: traffic light stock level indicator

<?php
if (zen_get_products_stock((int)$_GET['products_id']) >1) {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_green.gif', '', 10, 10) . '';
}

elseif (zen_get_products_stock((int)$_GET['products_id']) <1) {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_red.gif', '', 10, 10) . '';
}

else {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_yellow.gif', '', 10, 10) . '';
}
echo 'I SEE ' . $zc_stock_level_image;
?>

Put the final $zc_stock_level_image where you want to see the quantity and the dot ...

4 May 2007, 3:19 AM
#10
modchipfitters_co_uk avatar

modchipfitters_co_uk

Zen Follower

Join Date:
Sep 2006
Location:
United Kingdom
Posts:
190
Plugin Contributions:
0

Re: traffic light stock level indicator

ok lets see how bad i can break my site lol
here goes..............

4 May 2007, 3:23 AM
#11
modchipfitters_co_uk avatar

modchipfitters_co_uk

Zen Follower

Join Date:
Sep 2006
Location:
United Kingdom
Posts:
190
Plugin Contributions:
0

Re: traffic light stock level indicator

well that started well cant even fine the right file to edit :blush:
where is the file located???????

4 May 2007, 3:33 AM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: traffic light stock level indicator

The original file is in:
/includes/templates/template_default/tpl_product_info_display.php

copy to your templates and overrides directory first:
/includes/templates/your_template_dir/tpl_product_info_display.php

30 Sep 2008, 7:54 PM
#13
dscott1966 avatar

dscott1966

Zen Follower

Join Date:
Apr 2005
Posts:
298
Plugin Contributions:
0

Re: traffic light stock level indicator

Ok it works on the product info page. How do you get it to work on the product listing page. I tried everything.

I just want it to show the icons on the page the green, yellow, red icons. i want it to show between the price and more info button?

Can be seen here where i want to place it: http://dealz-r-us.com/index.php?main_page=index&cPath=1_2_3

Thank you

1 Oct 2008, 3:38 AM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: traffic light stock level indicator

You need to find the proper products_id ... on the product _info page it used:
(int)$_GET['products_id']

On the Listing, you need to locate the valid products_id for that page(s) ...

1 Oct 2008, 3:52 AM
#15
dscott1966 avatar

dscott1966

Zen Follower

Join Date:
Apr 2005
Posts:
298
Plugin Contributions:
0

Re: traffic light stock level indicator

Ajeh:

You need to find the proper products_id ... on the product _info page it used:
(int)$_GET['products_id']

On the Listing, you need to locate the valid products_id for that page(s) ...

Ok you lost me here. It works for the product info page. wouldn't the same code you have here work on the product listing page? Am i correct in saying?

 <?php 
if (zen_get_products_stock((int)$_GET['products_id']) >1) { 
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_green.gif', '', 10, 10) . ''; 
} 

elseif (zen_get_products_stock((int)$_GET['products_id']) <1) { 
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_red.gif', '', 10, 10) . ''; 
} 

else { 
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_yellow.gif', '', 10, 10) . ''; 
} 
echo 'I SEE ' . $zc_stock_level_image; 
?>  
```If so i'm just having a problem with putting the code in the page so it would show between the price and the more info button. Everything that i try does not work either it is on the top or it just does not show at all or the page goes blank. I just needed help on where the code would go.
4 Oct 2008, 4:23 AM
#16
dscott1966 avatar

dscott1966

Zen Follower

Join Date:
Apr 2005
Posts:
298
Plugin Contributions:
0

Re: traffic light stock level indicator

I've tried to do the above and do what Mrs. Linda says, but i just can't get it. Wish i knew a little more of coding. Can someone tell me how to do this, what code would i use, and what page, and where i would place it.

I'm going nuts trying to figure this out for the last few days. :cry:

Thank you

4 Oct 2008, 5:09 PM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: traffic light stock level indicator

If you are working on the Product Listing, you are most likely working with the:
/includes/modules/product_listing.php

and would reference the products_id with:
$listing->fields['products_id']

See if that works better for you ... :smile:

4 Oct 2008, 7:09 PM
#18
dscott1966 avatar

dscott1966

Zen Follower

Join Date:
Apr 2005
Posts:
298
Plugin Contributions:
0

Re: traffic light stock level indicator

Ajeh:

If you are working on the Product Listing, you are most likely working with the:
/includes/modules/product_listing.php

and would reference the products_id with:
$listing->fields['products_id']

See if that works better for you ... :smile:

I Kind of understand what your saying tell me if i have the code right here?

<?php 
if (zen_get_products_stock((int)$listing->fields['products_id']) >1) { 
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_green.gif', '', 10, 10) . ''; 
} 

elseif (zen_get_products_stock((int)$listing->fields['products_id']) <1) { 
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_red.gif', '', 10, 10) . ''; 
} 

else { 
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_yellow.gif', '', 10, 10) . ''; 
} 
echo 'I SEE ' . $zc_stock_level_image; 
?>  
```Do i have that correct?

Now my second question is this where in that file would i place the code?
4 Oct 2008, 8:40 PM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: traffic light stock level indicator

You would need to change the code in your templates and overrides directory for the file:
/includes/modules/products_listing.php

and copy that to:
/includes/modules/your_template_dir/products_listing.php

and if you had, for example, the Product Qty showing and wanted the dot next to it you can use:

        case 'PRODUCT_LIST_QUANTITY':
        $lc_align = 'right';
        $lc_text = $listing->fields['products_quantity'];
if (zen_get_products_stock((int)$listing->fields['products_id']) >1) {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_green.gif', '', 10, 10) . '';
}

elseif (zen_get_products_stock((int)$listing->fields['products_id']) <1) {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_red.gif', '', 10, 10) . '';
}

else {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_yellow.gif', '', 10, 10) . '';
}
$lc_text .= $zc_stock_level_image;

        break;

Otherwise, you can add that to any active field that you are using in the CASE statements ...

4 Oct 2008, 9:52 PM
#20
dscott1966 avatar

dscott1966

Zen Follower

Join Date:
Apr 2005
Posts:
298
Plugin Contributions:
0

Re: traffic light stock level indicator

Ajeh:

You would need to change the code in your templates and overrides directory for the file:
/includes/modules/products_listing.php

and copy that to:
/includes/modules/your_template_dir/products_listing.php

and if you had, for example, the Product Qty showing and wanted the dot next to it you can use:

    case 'PRODUCT_LIST_QUANTITY':
    $lc_align = 'right';
    $lc_text = $listing->fields['products_quantity'];

if (zen_get_products_stock((int)$listing->fields['products_id']) >1) {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_green.gif', '', 10, 10) . '';
}

elseif (zen_get_products_stock((int)$listing->fields['products_id']) <1) {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_red.gif', '', 10, 10) . '';
}

else {
$zc_stock_level_image = '' . $products_quantity . zen_image(DIR_WS_TEMPLATE_ICONS . 'icon_status_yellow.gif', '', 10, 10) . '';
}
$lc_text .= $zc_stock_level_image;

    break;

Thanks that worked for me. THats twice you have helped me Linda i owe you. :clap: