Created
May 2, 2018 19:50
-
-
Save MacgyverMartins/41318a8524e5e39d32c8e6c3232ca348 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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