woocommerce update price by quantity

This Snippets calculates the total price if you are using something like packaging units where multiple same items are within one purchasable product.

<div id="totals"> </div>
<script>
window.onkeyup = keyup;
var quantity;
var ep = 99
var vpe = 10
function keyup(e) {
  input = e.target.value;
  parseInt(quantity);
  parseInt(base);
  var price = quantity * ep;
  var pieces = quantity * vpe;
  console.log(price);
  console.log(quantity);
  console.log(ep);
  console.log(pieces);
  console.log("Total Price: $" + price + ",00");
  console.log("Amount Items: " + pieces);
  document.getElementById("totals").innerHTML += "Items Total: " + pieces + “
 Price Total: $" + price + “
";
}
</script>

WHERE TO PLACE THIS CODE?

Place this snippet at your desired spot wihtin a html block (or widget), where the total pricing should be visible.

Pleasure?

Please share your thumbsup, suggestions, edits, and questions within my comment section down there. 

I love posting snippets for you, but with a bit of feedback, it gets even more fun. 😀

Sharing is caring:

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert