0

is it possible to change price of product before add to cart through javascript in magento 2? I can't use observer because I am calculating price on product view page through users..

1 Answer 1

0

I would use the js to add a hidden input field with the calculated price and then add my own logic to an observer to update product price according to the input field.

However, you must assume that the value coming from the client is tampered and you can not really rely on that value. So you have to be able to verify the price on backend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.