Jump to content

Hide Out of Stock products from product-list.tpl


Recommended Posts

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 by Lugorcorp (see edit history)
Link to comment
Share on other sites

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

  • 11 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...