anth.payne Posted October 13, 2009 Share Posted October 13, 2009 I am currently attempting to look into the possibility of having a 'Traffic Light' type system for stock levels. I don't think it is ideal displaying QTY of stock available, nor is it ideal just having in stock/out of stock message.I think it would be a good idea to have something along the lines of:Out of Stock = RedLess then 10 in stock = AmberMore than 10 in stock = GreenWhether this would be a separate traffic light type image or whether the background colour of 'Add to Cart' button changes...I was hoping someone may beable to point me in the right direction of making these sorts of edits, or whether someone has achieved this already?PLEASE HELP!------------------------------------------------------------SOLVEDAs in my posts below, I have now achieved this. To get this working in the Product details page, Product list and Featured products page on the homepage, three files need changing:/themes/prestashop/product.tpl/themes/prestashop/product-list.tpl/modules/homefeatured/homefeatured.tplI have attached the 3 files in a zip, along with a green, amber and red traffic light images if you wish to use, or feel free to create your own.You will need to edit the location of the images in the attached files. Open them, and search amber.png (or green, or red).It is essential that you have 'Display available quantities on product page' enabled within Preferences >> Products for this to work.ENJOY... Traffic-Lights.zip 2 Link to comment Share on other sites More sharing options...
CYTechnologies Posted October 13, 2009 Share Posted October 13, 2009 Hey auth.payne,This would be quite easy to accomplish, open your product view template and do some quick if else statements. <?php if($quantity < 10) { ?> Yellow light <?php } else if($quantity == 0) { ?> Red - out of stock <?php } else { <?php Green - all is good. ?> <?php } ?> This should give you a direction at least Link to comment Share on other sites More sharing options...
geiri Posted October 14, 2009 Share Posted October 14, 2009 This is could look nice.. Link to comment Share on other sites More sharing options...
Troy Posted October 15, 2009 Share Posted October 15, 2009 Where can I find the folder? I tried looking at themes>mytheme>product-list.tplthemes>mytheme>product.tplthemes>mytheme>product-sort.tplThanks Link to comment Share on other sites More sharing options...
CYTechnologies Posted October 15, 2009 Share Posted October 15, 2009 I had a chance to look at the products page finally hahado a search for "number of item in stock"and you will see the below code: quantity == 0)} style="display:none;"{/if}> {$product->quantity|intval} quantity > 1} style="display:none;"{/if} id="quantityAvailableTxt">{l s='item in stock'} quantity < 2} style="display:none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'} PS is already doing the quantity checks, you just have to put in your images for green, yellow, or red in comparison to the above conditions.So for example: {if $product->quantity <= 0} {/if} {if $product->quantity >= 1 && $product->quantity <=5} {/if} {if $product->quantity >=6} {/if} Hope that helps point everyone in the right direction :-) Link to comment Share on other sites More sharing options...
Son Ame Posted October 24, 2009 Share Posted October 24, 2009 Yes. Pls advice how to make the same?see picture.Ty Link to comment Share on other sites More sharing options...
ysco Posted October 24, 2009 Share Posted October 24, 2009 Would be nice if someone could make this as a module to simple implemend this.Would be great as it could be as the sample Son Ame shows.Best regards,ysco.. Link to comment Share on other sites More sharing options...
anth.payne Posted October 25, 2009 Author Share Posted October 25, 2009 After some playing around with the PHP, think i've come up with a solution...The attached product.tpl file will show "Availability: *traffic-lights.png*" under the priceIf you replace the product.tpl file with the attached file, and create a couple of images (not forgetting to edit the image locations in the file) (NB - Look in the 'Availability' and 'Number of Item in Stock' sections)It is important that within Preferences > Products, you must make the following setting to get it to function correctly:Allow out of stock ordering: NoDisplay available quantities on product page: Yes#Unfortunately I am now struggling with the Product-List.tpl file, i've edited the code, so the traffic light appears below the View button (as opposed to instock/out of stock appearing to the left of the price). Problem being i cant get the right traffic light to appear, its either red, or green! (green when it should be amber). Link to comment Share on other sites More sharing options...
anth.payne Posted October 25, 2009 Author Share Posted October 25, 2009 files attached in zip**Old Files Removed** Link to comment Share on other sites More sharing options...
Son Ame Posted October 26, 2009 Share Posted October 26, 2009 i have a problem with productlist tpl too.Thank you very much Link to comment Share on other sites More sharing options...
anth.payne Posted October 26, 2009 Author Share Posted October 26, 2009 OK - done the product-list.tpl file.Now the traffic lights will appear as below: Link to comment Share on other sites More sharing options...
CYTechnologies Posted October 26, 2009 Share Posted October 26, 2009 Great job anth.payne! Link to comment Share on other sites More sharing options...
anth.payne Posted October 26, 2009 Author Share Posted October 26, 2009 Working Files attachedNB - remember to creat traffic light images and replace the img location in the files prestashop.zip Link to comment Share on other sites More sharing options...
ysco Posted October 26, 2009 Share Posted October 26, 2009 I have to try this Thanks for sharing anth.payneBest regards,ysco.. Link to comment Share on other sites More sharing options...
anth.payne Posted October 26, 2009 Author Share Posted October 26, 2009 Whilst I was on a roll, i've modded the featured products module in the same way.replace the file /modules/homefeatured/homefeatures.tpl with the one in the post below Link to comment Share on other sites More sharing options...
anth.payne Posted October 26, 2009 Author Share Posted October 26, 2009 file attached homefeatured.zip Link to comment Share on other sites More sharing options...
anth.payne Posted October 27, 2009 Author Share Posted October 27, 2009 Edited OP, and attached all files, inc. images in one download Link to comment Share on other sites More sharing options...
Son Ame Posted October 29, 2009 Share Posted October 29, 2009 Oh! Ty vm!u are greate! Link to comment Share on other sites More sharing options...
Masternet Posted November 1, 2009 Share Posted November 1, 2009 Hello,Homefeatured and product-list works fine, but product.tpl don't.When stock is 0 nothing happensWhen stock is < 5 works fineWhen Stock is > 5 this happensCan you fix that?Thanks Link to comment Share on other sites More sharing options...
anth.payne Posted November 1, 2009 Author Share Posted November 1, 2009 Which files have you downloaded? I was having similar issue initially.Make sure you are using the files in the Original Post.Also, ensure that 'Allow Out of Stock Ordering' is disabled in Preferences > Products, this seems to break the traffic lights when stock is 0. Link to comment Share on other sites More sharing options...
Masternet Posted November 1, 2009 Share Posted November 1, 2009 Which files have you downloaded? I was having similar issue initially.Make sure you are using the files in the Original Post.Also, ensure that 'Allow Out of Stock Ordering' is disabled in Preferences > Products, this seems to break the traffic lights when stock is 0. I have downloaded the files you attached hereI have disabled the stock ordering and seems works fine when stock is 0, but when stock is more than 6 still having problems. Link to comment Share on other sites More sharing options...
anth.payne Posted November 1, 2009 Author Share Posted November 1, 2009 Please attach the products.tpl file you are using, i'll take a look, make sure i sent the right one Seems to be working fine for me... Link to comment Share on other sites More sharing options...
Masternet Posted November 1, 2009 Share Posted November 1, 2009 Here it isThanks Link to comment Share on other sites More sharing options...
anth.payne Posted November 1, 2009 Author Share Posted November 1, 2009 you will need to zip it, as tpl files wont attach Link to comment Share on other sites More sharing options...
Masternet Posted November 1, 2009 Share Posted November 1, 2009 OkHere it is product.zip Link to comment Share on other sites More sharing options...
anth.payne Posted November 1, 2009 Author Share Posted November 1, 2009 Took a brief look, it looks like this may be because the combination quantity overrides the default product quantity.I am assuming the number displayed is the QTY available for that given combination selection?If you want to take a look at the `// Combinations` section i think the issue is here.If not it'll be a few days before i can troubleshoot this behaviour. Link to comment Share on other sites More sharing options...
doigro Posted April 12, 2010 Share Posted April 12, 2010 There are some problems when product has attributes. On my website the traffic light dissapears randomly. Is this happening to you? I'm using 1.2.5. Link to comment Share on other sites More sharing options...
ihackpro Posted April 12, 2010 Share Posted April 12, 2010 Thanks for the module!Is there any way to insert a similar behaviour but adding a image saying "under order" or "available in 1 week"?The shop I am configuring doesn't have stock so I have "allow to order without stock", and want to insert an image to let the client see that have to wait a few days.Thanks in advance Link to comment Share on other sites More sharing options...
anth.payne Posted April 14, 2010 Author Share Posted April 14, 2010 I beleive there is a problem when a product has combinations resulting in images not appearing - unfortunately I have not had the time to look at this.With regards to the 'Available in x days' - this is a feature already available, but not using an image - to use an image you would need have the same image for ALL out of stock products. Otherwise for each individual product you would need to edit the 'override the default out of stock message'. Link to comment Share on other sites More sharing options...
doigro Posted August 7, 2010 Share Posted August 7, 2010 up! up! Link to comment Share on other sites More sharing options...
LukeH Posted August 10, 2010 Share Posted August 10, 2010 I beleive there is a problem when a product has combinations resulting in images not appearing - unfortunately I have not had the time to look at this.With regards to the 'Available in x days' - this is a feature already available, but not using an image - to use an image you would need have the same image for ALL out of stock products. Otherwise for each individual product you would need to edit the 'override the default out of stock message'. This is a great mod for PrestaShop although I have found that I have a problem with items that have combination's not showing the images and still displaying stock quantities.Any idea which file creates combo's? I'll take a look at it.Luke. Link to comment Share on other sites More sharing options...
anth.payne Posted August 10, 2010 Author Share Posted August 10, 2010 Firstly I'd just like to apologise for my lack of input on this - things are a bit hectic currently.If you take a look in product.tplThere is a section //Combinations which references the combination quantity. I'm not 100% certain this is what the cause is but is certainly suspicious.You can reference the sections <!-- availability --> and <!-- number of item in stock --> in product.tpl for the logic i used for displaying the traffic lights. Link to comment Share on other sites More sharing options...
nikmagnus Posted March 9, 2011 Share Posted March 9, 2011 Hi thereI have a (in my humble opinion) a better way to do this. Im using PS1.4.0.15Instead of having a traffic light, I have a red sign for out of stock an amber sign for low on stock or a green light for lots of stock. This seems like a much more intuitive way. Next to it says the amount of stock left.See the included image.Simply modify the "number of items in stock" section of the product.tpl in your theme.Here is what I've done: <!-- number of item in stock --> available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}> {if $product->quantity > 5}{l s='Plenty in Stock'} {elseif $product->quantity > 0}{l s='Only '}{$product->quantity|intval}{l s=' left in stock'} {elseif $product->quantity < 1}{l s='None left in stock'} {/if} Also included are the icons needed to drive this: put inside yourtheme/img/icon folder.Hope you find this useful!Cheers, Nik stop-go-warning.zip Link to comment Share on other sites More sharing options...
Josraso Posted October 1, 2011 Share Posted October 1, 2011 how to make this modification work in ps 1.4, anyone can put thecode. thanks Link to comment Share on other sites More sharing options...
CSilva Posted April 12, 2013 Share Posted April 12, 2013 Hi there I have a (in my humble opinion) a better way to do this. Im using PS1.4.0.15 Instead of having a traffic light, I have a red sign for out of stock an amber sign for low on stock or a green light for lots of stock. This seems like a much more intuitive way. Next to it says the amount of stock left. See the included image. Simply modify the "number of items in stock" section of the product.tpl in your theme. Here is what I've done: <!-- number of item in stock --> available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}> {if $product->quantity > 5}[img={$img_dir}icon/go.png]{l s='Plenty in Stock'} {elseif $product->quantity > 0}[img={$img_dir}icon/warning.png]{l s='Only '}{$product->quantity|intval}{l s=' left in stock'} {elseif $product->quantity < 1}[img={$img_dir}icon/stop.png]{l s='None left in stock'} {/if} Also included are the icons needed to drive this: put inside yourtheme/img/icon folder. Hope you find this useful! Cheers, Nik Hi there, could this work to create something similar (like in the attached picture), in Prestashop 1.5? thanks, Link to comment Share on other sites More sharing options...
snakefd99cb Posted April 14, 2013 Share Posted April 14, 2013 Hello, You can see one here http://www.prestashop.com/forums/topic/210959-inclusion-de-un-semaforo-de-stock-en-la-web/ The thread is in spanish, sorry. Best regards 1 Link to comment Share on other sites More sharing options...
todaytonight Posted April 15, 2013 Share Posted April 15, 2013 it looks very nice. will try maybe... Link to comment Share on other sites More sharing options...
Alex Nitu Posted May 26, 2015 Share Posted May 26, 2015 Hi, I'm trying to use this module but I'm having problems getting it to work. I don't know what's the extra code I need to copy inside my tpl files for this to work. Link to comment Share on other sites More sharing options...
speedbit Posted June 3, 2015 Share Posted June 3, 2015 Hi, anyone can tell me if this will work on Prestashop 1.6.0.14?? Thanks in advance! 1 Link to comment Share on other sites More sharing options...
joaowoy Posted June 2, 2016 Share Posted June 2, 2016 (edited) I uploud the file produtcts.tpl , and show the error 500 internal server! Edited June 2, 2016 by joaowoy (see edit history) Link to comment Share on other sites More sharing options...
AngelSpeedy Posted September 8, 2016 Share Posted September 8, 2016 Hi, this look very nice but is not working with 1.4.11.0 version, can you see what is the problem ? Can you help me ? Tks.. Link to comment Share on other sites More sharing options...
Recommended Posts