FluffyCat Posted May 28, 2014 Share Posted May 28, 2014 Hi I am making a minor change in product.tpl for my theme. I simply want to show a specific image when the product is in stock and another image when it is not. This works almost perfectly simply using $product->quantity. However, if the product is out of stock in a certain color but is in stock in another color, then $product->quantity still says there is products in stock when I am looking at the color that is out of stock. So I guess $product->quantity is the quantity for all items in stock of this product regardless of color. How can I get the number of products in stock with the color that is currently being shown to the user. Prestashop seems to handle this correctly but I do not understand how they do it. Thanks in advice for any hints. 1 Link to comment Share on other sites More sharing options...
CartExpert.net Posted May 30, 2014 Share Posted May 30, 2014 Hi. What version of PrestaShop are you using? Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
FluffyCat Posted May 30, 2014 Author Share Posted May 30, 2014 Hi Sorry I forgot to add that, it is 1.5.4.1. I have seen that the combinations are managed from the js file in the theme so it is working ok now. However it would be really interesting to know if this can be managed from the tpl file to simplify things but maybe that is not an option? Link to comment Share on other sites More sharing options...
CartExpert.net Posted May 31, 2014 Share Posted May 31, 2014 Hi. The combination quantities are stored in a JS array. You can retrieve them from the 'combinations' array via JS. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
typ3z3r0 Posted June 24, 2014 Share Posted June 24, 2014 (edited) The problem is that PrestaShop sets $product->quantity to the sum of all quantities for all combinations for the product. I have a problem with this at the moment. I have code to change the colour/class of #availability_value when the combination has a quantity of zero or less. Unfortunately, since I have another combination, which does have stock, $product->quantity is being set to 6 (because one combination, the one for pre-ordering, has 0 in stock, while the other has 6 in stock). Is there an easy way to fix this bug?EDIT: Nevermind. I achieved what I needed to by modifying product.js. Edited June 25, 2014 by typ3z3r0 (see edit history) 1 Link to comment Share on other sites More sharing options...
gr_fenix Posted July 7, 2015 Share Posted July 7, 2015 Can you give more details how you do it? Thanks Link to comment Share on other sites More sharing options...
Myles_UA Posted March 28, 2017 Share Posted March 28, 2017 How can i show quantities of each combinations in admin product list? Prestashop 1.6 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