Jump to content

Showing product quantity on products list and on product page


thn_

Recommended Posts

I know there is an option to show quantity on product page in details section, but it is way to hidden, I want to show available quantity on product list and product page next to add to cart button. I've copied 

{block name='product_quantities'}
    {if $product.show_quantities}
        <div class="product-quantities">
            <label class="label">{l s='In stock' d='Shop.Theme.Catalog'}</label>
            <span data-stock="{$product.quantity}" data-allow-oosp="{$product.allow_oosp}">{$product.quantity} {$product.quantity_label}</span>
        </div>
    {/if}
{/block}

to product-list.tpl and it works, shows available quantity, but not like it should. On category page it shows for example available 100 pieces, when I'll add 10 to cart it changes from "available 100 pieces" to "available 10 pieces", if i'll add 10 more pieces then it turns into "available 20 pieces" etc. On the other hand I've added this code to product-prices.tpl right under reference, and it shows "available 100 pieces", but when I'll add 10 to cart it still says "available 100 pieces" when same piece of code in product details works like it should (after adding 10 to cart shows 90 available).

Where I'm making mistake?

Link to comment
Share on other sites

What is your PS version?

You have to put the code into themes/yourtheme/catalog/_partials/miniatures/product.tpl. Following code works and have the right stock quantity available decrease with cart.

{block name='product_quantities'}
      <div class="product-quantities">
        <label class="label">{l s='In stock' d='Shop.Theme.Catalog'}</label>
        <span data-stock="{$product.quantity}" data-allow-oosp="{$product.allow_oosp}">{$product.quantity} {$product.quantity_label}</span>
      </div>
  {/block}

 

Edited by Prestashop Addict (see edit history)
  • Thanks 1
Link to comment
Share on other sites

18 hours ago, Prestashop Addict said:

What is your PS version?

You have to put the code into themes/yourtheme/catalog/_partials/miniatures/product.tpl. Following code works and have the right stock quantity available decrease with cart.

{block name='product_quantities'}
      <div class="product-quantities">
        <label class="label">{l s='In stock' d='Shop.Theme.Catalog'}</label>
        <span data-stock="{$product.quantity}" data-allow-oosp="{$product.allow_oosp}">{$product.quantity} {$product.quantity_label}</span>
      </div>
  {/block}

 

Video of what is happening in category page:

 

 

Video showing what is happening on product page:

 

 

I have PS 1.7.8.5, theme Warehouse.

Link to comment
Share on other sites

  • 1 year later...

Hi I just found this and it is working on PS8.2.0.

Here there a way I can have the stock levels show as seen in the screenshot below?

 

Also I would like the word "Array" to not appear.

Show Stock.png

Edited by retechp
correction to original post (see edit history)
Link to comment
Share on other sites

25 minutes ago, Knowband Plugins said:

What code have you added and in which file?

What's the PS version?

I am using PS 8.2.0 and I added this right after line 127 in themes/classic/catalog/_partials/miniatures/

{block name='product_quantities'}
      <div class="product-quantities">
        <label class="label">{l s='Stock' d='Shop.Theme.Catalog'}</label>
        <span data-stock="{$product.quantity}" data-allow-oosp="{$product.allow_oosp}">{$product.quantity} {$product.quantity_label}</span>
      </div>
  {/block}

 

Link to comment
Share on other sites

Then add only.

{block name='product_quantities'}
      <div class="product-quantities">
        <label class="label">{l s='Stock' d='Shop.Theme.Catalog'}</label>
        <span data-stock="{$product.quantity}" data-allow-oosp="{$product.allow_oosp}">{$product.quantity}</span>
      </div>
  {/block}

i.e.  Remove  {$product.quantity_label}

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Knowband Plugins said:

Then add only.

{block name='product_quantities'}
      <div class="product-quantities">
        <label class="label">{l s='Stock' d='Shop.Theme.Catalog'}</label>
        <span data-stock="{$product.quantity}" data-allow-oosp="{$product.allow_oosp}">{$product.quantity}</span>
      </div>
  {/block}

i.e.  Remove  {$product.quantity_label}

Thanks for that.  Also, is there any way to center the text as illustrated in "after" screenshot above?

Link to comment
Share on other sites

  • 2 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...