Jump to content
abe666

Display stock availability in product listing for Prestashop 1.7.3

Recommended Posts

Hi, help me with code to diplay information label product stock availability In Stock / Out of Stock in product listing.

Sample in attached picture.

For for Prestashop 1.7.3

 

Thanks

Screenshot-2018-4-13 Sekačky.png

 

Partialy Solved:

      {block name='product_miniature_item'}
        {if $product.quantity > 0}
            <span class="availability-list">In Stock</span>
        {/if}
      {/block}

 

 

Edited by abe666 (see edit history)

Share this post


Link to post
Share on other sites

hello
Why partially solved?
 

if you will use {else} with <span>out of stock</span> it should do the job. Or i missed something?

Share this post


Link to post
Share on other sites
On 27/5/2018 at 8:13 PM, rif_catalan said:

 

hi, and how to make it look green for available and red color for sold out, for ps 1.7.2.4 thanks  ??

 

This is a simple CSS question : )

Just add two classes in your if/else statement.

Share this post


Link to post
Share on other sites

I also need this, but I have no idea whre to put that code or what is needed beforehand. Is there a module, even if paid, for that?

Thank you

Share this post


Link to post
Share on other sites

In your themefolder/templates/catalog/_partials/miniatures/product.tpm just before the the "thumbnail-container" div closes

 

{block name='product_miniature_item'}
        {if $product.quantity > 0}
            <span class="availability-list availability-list-in-stock">In Stock</span>

       {else}

            <span class="availability-list availability-list-out-of-stock">Out of Stock</span>
        {/if}
 {/block}

 

And in themefolder/assests/css/custom.css file (for example) something like

 

.availability-list{

padding: 4px;

color:white;

position: absolute;

right:0;

bottom:0;

}

.availability-list-in-stock{

background-color: green;

}

.availability-list-out-of-stock{

background-color red;

}

.thumbnail-container{

position: relative

}

That last one was just so that the text stays in the thumbnail, it may not be needed depending on your theme.

Keep in mind that i did not test this code but it should about work. 

 

Edited by Henri (see edit history)
  • Like 2

Share this post


Link to post
Share on other sites
On 29/6/2018 at 5:45 PM, Henri said:

In your themefolder/templates/catalog/_partials/miniatures/product.tpm just before the the "thumbnail-container" div closes

 

{block name='product_miniature_item'}
        {if $product.quantity > 0}
            <span class="availability-list availability-list-in-stock">In Stock</span>

       {else}

            <span class="availability-list availability-list-out-of-stock">Out of Stock</span>
        {/if}
 {/block}

 

And in themefolder/assests/css/custom.css file (for example) something like

 

.availability-list{

padding: 4px;

color:white;

position: absolute;

right:0;

bottom:0;

}

.availability-list-in-stock{

background-color: green;

}

.availability-list-out-of-stock{

background-color red;

}

.thumbnail-container{

position: relative

}

That last one was just so that the text stays in the thumbnail, it may not be needed depending on your theme.

Keep in mind that i did not test this code but it should about work. 

 

running in the latest version of prestashop

Share this post


Link to post
Share on other sites
On 6/29/2018 at 5:45 PM, Henri said:

.availability-list-out-of-stock{

background-color red;

}

Well, correcting "background-color red;" to "background-color : red;" helped a lot. Also, running position: center allows for a better placement with the quick-view. Done the following hack as well, changing the "quick-view" translation to "Quick-view ::" makes it a little more pretty.

Hope it helps someone!

 

Stock-avail.jpg

Stock-avail2.jpg

Share this post


Link to post
Share on other sites
Posted (edited)

What about product with versions?
This solution works only when default version has count > 0 or product has no versions.

Ok, i checked and found this:

$product['quantity_all_versions']

 

Edited by almakot (see edit history)

Share this post


Link to post
Share on other sites

Hi i want to do this but with every size like that:

Captffure.PNG.0f4aa9324ddd4d49c1bf0f4d67a0f877.PNG

Do you have any idea ?

Share this post


Link to post
Share on other sites

In Prestashop 1.7.*, Product.tpl. You should use ' product.quantity_all_versions '

{block name='product_miniature_item'}
                {if $product.quantity_all_versions < 1}
                    <span class="availability-list availability-list-out-of-stock">Out Of Stock</span>
                {/if}
             {/block} 

  • Like 1

Share this post


Link to post
Share on other sites

Can u help me ?

I have prestashop 1.7.6.1 and doesnt work this code :(

On 6/29/2018 at 5:45 PM, Henri said:

In your themefolder/templates/catalog/_partials/miniatures/product.tpm just before the the "thumbnail-container" div closes

 

{block name='product_miniature_item'}
        {if $product.quantity > 0}
            <span class="availability-list availability-list-in-stock">In Stock</span>

       {else}

            <span class="availability-list availability-list-out-of-stock">Out of Stock</span>
        {/if}
 {/block}

 

And in themefolder/assests/css/custom.css file (for example) something like

 

.availability-list{

padding: 4px;

color:white;

position: absolute;

right:0;

bottom:0;

}

.availability-list-in-stock{

background-color: green;

}

.availability-list-out-of-stock{

background-color red;

}

.thumbnail-container{

position: relative

}

That last one was just so that the text stays in the thumbnail, it may not be needed depending on your theme.

Keep in mind that i did not test this code but it should about work. 

 

Can u help me ?

I have prestashop 1.7.6.1 and doesnt work this code :(😢

Share this post


Link to post
Share on other sites
On 10/8/2019 at 3:35 PM, Bosiu said:

Can u help me ?

I have prestashop 1.7.6.1 and doesnt work this code :(

Can u help me ?

I have prestashop 1.7.6.1 and doesnt work this code :(😢

Same here, nobody have the answer ?

With this code impossible to get quantity of current product.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More