Jump to content

how to read variable


koening

Recommended Posts

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?

  • Like 1
Link to comment
Share on other sites

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.

 

 

4sONEAq.jpg

 

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...