thn_ Posted March 19, 2024 Share Posted March 19, 2024 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 More sharing options...
Prestashop Addict Posted March 19, 2024 Share Posted March 19, 2024 (edited) 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 March 19, 2024 by Prestashop Addict (see edit history) 1 Link to comment Share on other sites More sharing options...
thn_ Posted March 20, 2024 Author Share Posted March 20, 2024 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 More sharing options...
Prestashop Addict Posted March 21, 2024 Share Posted March 21, 2024 I tested on PS 1.7.8.11 and 8.1.4 with classic theme Link to comment Share on other sites More sharing options...
retechp Posted April 11 Share Posted April 11 (edited) 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. Edited April 11 by retechp correction to original post (see edit history) Link to comment Share on other sites More sharing options...
Knowband Plugins Posted April 11 Share Posted April 11 What code have you added and in which file? What's the PS version? Link to comment Share on other sites More sharing options...
retechp Posted April 11 Share Posted April 11 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 More sharing options...
Knowband Plugins Posted April 11 Share Posted April 11 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} 1 Link to comment Share on other sites More sharing options...
retechp Posted April 11 Share Posted April 11 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 More sharing options...
Knowband Plugins Posted April 11 Share Posted April 11 3 minutes ago, retechp said: center the text as illustrated in "after" screenshot above Yes, the site URL will be required to provide the required CSS for the same. Link to comment Share on other sites More sharing options...
retechp Posted April 14 Share Posted April 14 Currently the site is on a vm that I am testing so I use http://172.16.0.8 Link to comment Share on other sites More sharing options...
rb10 Posted July 11 Share Posted July 11 This works also with PS 8 ? 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