Hello,
I have a JS problem I've been trying to solve for a few days now. My payment provider caps at $5,000 per transaction. When the total balance is greater than $5,000, how do I disable the checkout button and provide a message? The issue I'm having right now is getting the [BALANCE] value as a number, so that I can use if/then statement.
Here's what I have so far:
<div id="totalBalanceAmount" class="total_balance">[BALANCE]</div>
<button id="disableCheckoutButton" type="button" onclick="myFunction();doCheckout(this.form,'checko utButton');" class="btn"><i class="icon-basket"></i> [checkout3_submitbutton]</button>
<p id="notifytocall"></p>
<!--START: IF TOTAL IS GREATER THAN OR EQUAL TO 5000-->
<script type="text/javascript">
function myFunction() {
var totalOrderBalance = document.getElementById("totalBalanceAmount").inne rHTML;
document.getElementById("notifytocall").innerHTML = totalOrderBalance;
if (totalOrderBalance < 5) {
document.getElementById("notifytocall").innerHTML = "Your order is more than 5,000 dollars. Please call or email us to place your order. Thank you.";
document.getElementById("disableCheckoutButton").d isabled = true;
}
}
</script>
<!--END: IF TOTAL IS GREATER THAN OR EQUAL TO 5000-->
I checked the data type of "totalBalanceAmount" using typeof, and it says it's string. When I do "parseInt(document.getElementById("totalBalanc eAmo unt").innerHTML);", I get a NaN. Any ideas?
For now, I'm triggering by clicking on the checkout button but eventually I'd like it to be triggered when [BALANCE] changes (e.g., after selecting shipping option). If it helps, I'm using ../assets/templates/v32016-html5/checkout-singlepage-v2.html.
Best,
Mike
I have a JS problem I've been trying to solve for a few days now. My payment provider caps at $5,000 per transaction. When the total balance is greater than $5,000, how do I disable the checkout button and provide a message? The issue I'm having right now is getting the [BALANCE] value as a number, so that I can use if/then statement.
Here's what I have so far:
<div id="totalBalanceAmount" class="total_balance">[BALANCE]</div>
<button id="disableCheckoutButton" type="button" onclick="myFunction();doCheckout(this.form,'checko utButton');" class="btn"><i class="icon-basket"></i> [checkout3_submitbutton]</button>
<p id="notifytocall"></p>
<!--START: IF TOTAL IS GREATER THAN OR EQUAL TO 5000-->
<script type="text/javascript">
function myFunction() {
var totalOrderBalance = document.getElementById("totalBalanceAmount").inne rHTML;
document.getElementById("notifytocall").innerHTML = totalOrderBalance;
if (totalOrderBalance < 5) {
document.getElementById("notifytocall").innerHTML = "Your order is more than 5,000 dollars. Please call or email us to place your order. Thank you.";
document.getElementById("disableCheckoutButton").d isabled = true;
}
}
</script>
<!--END: IF TOTAL IS GREATER THAN OR EQUAL TO 5000-->
I checked the data type of "totalBalanceAmount" using typeof, and it says it's string. When I do "parseInt(document.getElementById("totalBalanc eAmo unt").innerHTML);", I get a NaN. Any ideas?
For now, I'm triggering by clicking on the checkout button but eventually I'd like it to be triggered when [BALANCE] changes (e.g., after selecting shipping option). If it helps, I'm using ../assets/templates/v32016-html5/checkout-singlepage-v2.html.
Best,
Mike
Comment