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)
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

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