Jump to content

Refreshing price through Java Script in product page


Recommended Posts

Hello

I have created a simple HTML/JS calculator and integrated through .tpl files on product page.
The problem is that when querySelector selects the option in variations, the product price dosen't change, but if i manually click with mouse on option the price does change.
So my questions is how could i refresh the price after the variation is selected through querySelector.

Any help would be greatly appreciated because iv been stuck on this part for like 2 weeks now.

Thanks.

Link to comment
Share on other sites

  • 2 weeks later...
On 9/10/2021 at 4:40 PM, endriu107 said:

I think you need add events https://devdocs.prestashop.com/1.7/themes/reference/javascript-events/#dispatched-events in this case probably on updatedProduct.

Thank you very much! I just put this code after querySelector:
if(a > 2007 && a < 2034 && p > 670 && p < 771 && k == "krypkair"){
    document.querySelector("#group_17 option[value='69']").selected = true;
    prestashop.emit('updateProduct', {
      reason: event.currentTarget.dataset
    });

  }
And now it updates price, thanks again!

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...