Jump to content

Update price


Recommended Posts

hi

i need help with finaly price. in shop front -> product site. I use javascript to counted new price but dont know how update price variable. now if i push cart button i adde product with old price.

selectElement2.addEventListener('change', (event) => {	
	
		var $max = parseInt($('#szerokosc').attr('max'));
		var $min = parseInt($('#szerokosc').attr('min'));
		var $wartosc = document.getElementById("szerokosc").value
  
	  if (document.getElementById("szerokosc").value>$max){
		  selectElement2.value = $max;
		  const result2 = document.querySelector('.errorMsg2');
		  result2.style.display = 'block';
		  result2.textContent = `Maksymalny wymiar to ` + $max + `cm`;
	  }
	  else if (document.getElementById("szerokosc").value<$min) {
		  selectElement2.value = $min;
		  const result2 = document.querySelector('.errorMsg2');
		  result2.style.display = "block";
		  result2.textContent = `Minimalny wymiar to ` + $min + `cm`;
	  }
	  else {
	  const result2 = document.querySelector('.errorMsg2');
	  result2.style.display = 'none';
	  var cenakoncowa = (cena/100)*$wartosc;
	  cenakoncowa = cenakoncowa.toFixed(2);
	  product.querySelector('[itemprop=price]').setAttribute('content',cenakoncowa);
	  product.querySelector('[itemprop=price]').innerHTML = cenakoncowa.replace("\.",",") + ' zł';
	  }

help pls.

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