knacky Posted April 5, 2020 Posted April 5, 2020 Hi to all. I need to know how to use JS for the product detail page. I would like to change the price when changing quantity. I would like to use the functions from product.js in Prestashop 1.7.> Version. I don't need to buy modules for> 49 €. I think it should be the default function in Prestashop. Thank you Share this post Link to post Share on other sites More sharing options...
joseantgv Posted April 5, 2020 Posted April 5, 2020 Price is changed by default if you have specific prices per quantity: 1 Share this post Link to post Share on other sites More sharing options...
knacky Posted May 2, 2020 Posted May 2, 2020 Thank you. When you change the quanti´ty, the price * quantity should also change. Share this post Link to post Share on other sites More sharing options...
JBW Posted May 2, 2020 Posted May 2, 2020 You can listen to "updatedProduct" event prestashop.on('updatedProduct', function() {alert("Updated")}); 1 Share this post Link to post Share on other sites More sharing options...
Guest Posted May 4, 2020 Posted May 4, 2020 (edited) On 5/2/2020 at 5:14 PM, JBW said: You can listen to "updatedProduct" event prestashop.on('updatedProduct', function() {alert("Updated")}); What's the answer? You can help more people by putting Custom JavaScript code here. Thank you Edited May 4, 2020 by Guest (see edit history) Share this post Link to post Share on other sites More sharing options...
JBW Posted May 4, 2020 Posted May 4, 2020 4 minutes ago, Guest said: What's the answer? The posted code it the answer to the given request. On 4/5/2020 at 9:26 AM, knacky said: I need to know how to use JS for the product detail page As this is a developer forum the author should be able to implement whatever logic he need by using the event lister - I agree would be nice to publish it here afterward so that other can benefit from it. 1 1 Share this post Link to post Share on other sites More sharing options...
Guest Posted May 4, 2020 Posted May 4, 2020 When I advise someone, I give full and functional codes. I am a programmer myself, but it is impossible to know all the functions without quality documentation. Unfortunately, the documentation for developers is insufficient. Share this post Link to post Share on other sites More sharing options...
Guest Posted May 4, 2020 Posted May 4, 2020 The user made a beautiful guide for Prestashop 1.6 User @NemoPS There is nothing for Prestashop 1.7. If you can do it, you will be the first 🙂 Share this post Link to post Share on other sites More sharing options...
knacky Posted May 7, 2020 Posted May 7, 2020 Well, that's bad. Does anyone really know and don't want to insert the custom javascript code? Share this post Link to post Share on other sites More sharing options...
trung_antking Posted January 5, 2021 Posted January 5, 2021 You can config it via Price -> Specific prices in product details page Share this post Link to post Share on other sites More sharing options...
presta_jsM Posted July 13, 2021 Posted July 13, 2021 I have this functionality in a custom Javascript. Like this: $('#quantity_wanted').change(function(e) { var price = $('.current-price span').attr("content"); var cant = parseFloat($('#quantity_wanted').val()); if (cant >= '1,00' || cant >= 1 || cant >= '1') { var total = '<span class="total-price"><span class="price-value"></span></span>'; $( ".product-quantity" ).html( total ); finalPrice = parseFloat(price) * parseFloat(cant); $('price-value').html(formatNumber.new((finalPrice.toFixed(2)).replace('.',','))); } }); I hope it helps. Share this post Link to post Share on other sites More sharing options...
Ramage Posted April 28 Posted April 28 On 7/13/2021 at 11:00 AM, presta_jsM said: I have this functionality in a custom Javascript. Like this: $('#quantity_wanted').change(function(e) { var price = $('.current-price span').attr("content"); var cant = parseFloat($('#quantity_wanted').val()); if (cant >= '1,00' || cant >= 1 || cant >= '1') { var total = '<span class="total-price"><span class="price-value"></span></span>'; $( ".product-quantity" ).html( total ); finalPrice = parseFloat(price) * parseFloat(cant); $('price-value').html(formatNumber.new((finalPrice.toFixed(2)).replace('.',','))); } }); I hope it helps. Can I copy and paste to my_theme/custom.js ? 1 Share this post Link to post 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