Skip to content

Instantly share code, notes, and snippets.

@MacgyverMartins
Created May 2, 2018 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MacgyverMartins/41318a8524e5e39d32c8e6c3232ca348 to your computer and use it in GitHub Desktop.
Save MacgyverMartins/41318a8524e5e39d32c8e6c3232ca348 to your computer and use it in GitHub Desktop.
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function changePagePrice() {
var spanPrice = document.getElementsByClassName('woocommerce-Price-amount')
spanPrice = spanPrice[spanPrice.length -1]
var price = parseFloat(spanPrice.textContent.replace(/\$/i, ''))
var days = parseInt(getParameterByName('days'))
var newPrice = '$' + (price * days)
spanPrice.textContent = newPrice
}
changePagePrice();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment