hellykun Posted April 24, 2015 Share Posted April 24, 2015 Dear Prestashop users, There are many questions for this matter and I would like to also post mine. As far as I have seen there is not a sufficient answer to that. I am using Prestashop 1.5 and I have some products with combinations. We have developed a specific system to check the availability of each product based on its combination. The problem is that if the product has combinations then the quantity is the sum of all the combinations. For example I have a PRODUCT with 2 combinations Combination 1 = 10 pieces Combinations 2 = 15 pieces If quantity = 10 pieces then the availability should be low If quantity = 15 pieces then the availability should be middle but the result is quantity = 25 pieces which means high Is it possible to get a combinations specific quantity within a TPL file? Thanks a lot in advance Link to comment Share on other sites More sharing options...
hellykun Posted April 27, 2015 Author Share Posted April 27, 2015 Solved it! You can tweak product.js and get the combinations quantity. Link to comment Share on other sites More sharing options...
Pervosvet59 Posted May 7, 2015 Share Posted May 7, 2015 Hi, can you, please, describe how did you solve it? Link to comment Share on other sites More sharing options...
hellykun Posted May 7, 2015 Author Share Posted May 7, 2015 Absolutely! We have two files product.tpl and product.js First, in product.js you can get the combination number with this code below for example selectedCombination['quantity'] = combinations[combination]['quantity']; if (selectedCombination['quantity'] <= 0){ $('#availability').html(HERE INSERT YOUR HTML CODE); }else if (selectedCombination['quantity'] >= 23){ $('#availability').html(HERE INSERT YOUR HTML CODE); }else if (selectedCombination['quantity'] >= 100){ $('#availability').html(HERE INSERT YOUR HTML CODE); } then in product.tpl you should add a specific #availability [iD to your div or span or whatever you want] to display what you want. for example {if isset($groups)} <!-- this checks if there are combinations --> <span id="availability"></span> <!-- this shows the html text of $('#availability').html --> {else} DO what you are supposed to do I hope I have helped! Link to comment Share on other sites More sharing options...
Pervosvet59 Posted May 8, 2015 Share Posted May 8, 2015 Actually that is not that I really thought. In my project I need to show quantity of each combination (i'm selling spray paint for me it's just color), and I have no idea how to display quantity of each color. Link to comment Share on other sites More sharing options...
hellykun Posted May 8, 2015 Author Share Posted May 8, 2015 Just display the selectedCombination['quantity'] with javascript. Link to comment Share on other sites More sharing options...
Pervosvet59 Posted May 15, 2015 Share Posted May 15, 2015 Thanks for help, but I got it with <p>{$group.attributes_quantity[{$id_attribute|intval}]|escape:'html':'UTF-8'}</p> added to product.tpl 1 Link to comment Share on other sites More sharing options...
hellykun Posted May 15, 2015 Author Share Posted May 15, 2015 thats great thanks for sharing! Link to comment Share on other sites More sharing options...
gr_fenix Posted July 7, 2015 Share Posted July 7, 2015 Absolutely! We have two files product.tpl and product.js First, in product.js you can get the combination number with this code below for example selectedCombination['quantity'] = combinations[combination]['quantity']; if (selectedCombination['quantity'] <= 0){ $('#availability').html(HERE INSERT YOUR HTML CODE); }else if (selectedCombination['quantity'] >= 23){ $('#availability').html(HERE INSERT YOUR HTML CODE); }else if (selectedCombination['quantity'] >= 100){ $('#availability').html(HERE INSERT YOUR HTML CODE); } then in product.tpl you should add a specific #availability [iD to your div or span or whatever you want] to display what you want. for example {if isset($groups)} <!-- this checks if there are combinations --> <span id="availability"></span> <!-- this shows the html text of $('#availability').html --> {else} DO what you are supposed to do I hope I have helped! In what line of product.js you put the code? Link to comment Share on other sites More sharing options...
Kaper Posted November 18, 2016 Share Posted November 18, 2016 I try this code in PS 1.6 but it is not working, can you please help me, step by step, what i have to do? And where i have to put code in product.JS ? THANKS! Link to comment Share on other sites More sharing options...
millien Posted January 3, 2019 Share Posted January 3, 2019 I need this as well . 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