koening Posted May 17, 2017 Share Posted May 17, 2017 Hi! How can I get value of javascript variable to cart.php file? I need information which user write in an input and I need to multiple price by this value in cart.php. Link to comment Share on other sites More sharing options...
NemoPS Posted May 17, 2017 Share Posted May 17, 2017 You can't read js in php, the only way you can do it is grab it before it's assigned to js. If it's pure js, you just can't, and need to find a way to get it from php.Presta version? edit: I might have misread what you wrote. Do you just mean read with javascript and multiply? 1 Link to comment Share on other sites More sharing options...
koening Posted May 17, 2017 Author Share Posted May 17, 2017 Sorry for my bad English :/ I want to sell products by square meters. In product price I am writting default price per m2 and now I want to have a calculator on my product page and I want to return my specific price calculated on a product page stored in javascript variable to cart.php. In $price is stored total product price in cart. Link to comment Share on other sites More sharing options...
koening Posted May 18, 2017 Author Share Posted May 18, 2017 (edited) Anyone can help me? This is important for me :/ Edited May 18, 2017 by koening (see edit history) Link to comment Share on other sites More sharing options...
razaro Posted May 18, 2017 Share Posted May 18, 2017 Hi First you can search I think there are few paid modules that already do that like https://addons.prestashop.com/en/sizes-units/8972-price-by-surface-volume-length-perimeter.html But if you developing your own solution, you can try to use ajax. So when some value is changed in JavaScript you call $.ajax and link some php script that will update product price. Note that is really tricky part and you need to override in right place so price is then displayed in cart, in order, pdf files. 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