Skip to content

Instantly share code, notes, and snippets.

@robertuniqid
Created February 13, 2018 12:20
Show Gist options
  • Save robertuniqid/9f923096b123d6418359937b524a60cf to your computer and use it in GitHub Desktop.
Save robertuniqid/9f923096b123d6418359937b524a60cf to your computer and use it in GitHub Desktop.
ThriveCart Hide Credit Cards if Price is 0
<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