Created
February 13, 2018 12:20
-
-
Save robertuniqid/9f923096b123d6418359937b524a60cf to your computer and use it in GitHub Desktop.
ThriveCart Hide Credit Cards if Price is 0
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
<script type="text/javascript"> | |
document.addEventListener('DOMContentLoaded', function () { | |
var myCustomPriceActions = function() { | |
var price = parseInt( document.querySelector("ul.order-details .order-details-total em[data-currency]").innerHTML.replace( "$", "" ) ); | |
var credit_card_element = document.querySelector("#form-order > .credit-cards" ); | |
if( price === 0 ) { | |
credit_card_element.style.display = "none"; | |
} else { | |
credit_card_element.style.display = "block"; | |
} | |
}; | |
/** Mutation Observers didn't seem to do the trick, we're cheating with timeouts **/ | |
myCustomPriceActions(); | |
setTimeout( function() { | |
myCustomPriceActions(); | |
}, 200 ); | |
setTimeout( function() { | |
myCustomPriceActions(); | |
}, 500 ); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment