Lugorcorp Posted August 17, 2015 Share Posted August 17, 2015 (edited) Hi guys,I want to hide (no disable from the DB) all the products who are out of stock from the featured products but I want keep them for reference for the customers.I'm editing "product-list.tpl" but I'm getting just a blank space.What can I do? Thanks Edited August 17, 2015 by Lugorcorp (see edit history) Link to comment Share on other sites More sharing options...
PhpMadman Posted August 17, 2015 Share Posted August 17, 2015 Can you post the code? My guess is that you are check the stock to late. It needs to be moved up before tpl is writing the needed li / divs. Link to comment Share on other sites More sharing options...
Lugorcorp Posted August 18, 2015 Author Share Posted August 18, 2015 (edited) Can you post the code? My guess is that you are check the stock to late. It needs to be moved up before tpl is writing the needed li / divs. I'm just doing something like this: {foreach from=$products item=product name=products} {math equation="(total%perLine)" total=$smarty.foreach.products.total perLine=$nbItemsPerLine assign=totModulo} {math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineTablet assign=totModuloTablet} {math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineMobile assign=totModuloMobile} {if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if} {if $totModuloTablet == 0}{assign var='totModuloTablet' value=$nbItemsPerLineTablet}{/if} {if $totModuloMobile == 0}{assign var='totModuloMobile' value=$nbItemsPerLineMobile}{/if} {if ($product.quantity < 0)} /* Out of stock */ #code {/if} {/foreach} Do you know what can I do? I'm new with smarty. Thanks. Edited August 18, 2015 by Lugorcorp (see edit history) Link to comment Share on other sites More sharing options...
PhpMadman Posted August 19, 2015 Share Posted August 19, 2015 I looked in to it... The reason for the blank space, is that <li> tag check the position based on product total and the position in the array. So product nr 5 goes to a new row because it has position 5 in the array. And should there for be called as a first-in-line items, since there should be only 4 products per row. To hide the products you need to instead modify the ProductController and remove the out of stock products before they get sent to the smarty. This is mainly because smart does not seem to support modifying an array. Link to comment Share on other sites More sharing options...
vekia Posted August 11, 2016 Share Posted August 11, 2016 you can achieve it with free tutorial based on mysql triggers: disabling the out of stock products 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now