Created
December 25, 2017 13:20
-
-
Save apih/4b64d083328ca4553dc2e935d29a1b1b to your computer and use it in GitHub Desktop.
Code for reverting (partially) OnPay's order form to classic look
This file contains 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).ready(function() { | |
$("#submit-order").hide(); | |
$("#payment_form").show(); | |
$("#payment_form").submit(function(event) { | |
event.preventDefault(); | |
return false; | |
}); | |
$("#total_amount").change(function() { | |
var totalAmount = $(this).val(); | |
if (totalAmount > 0) { | |
$("#submit-order").hide(); | |
$("#payment_form").show(); | |
} else { | |
$("#submit-order").show(); | |
$("#payment_form").hide(); | |
} | |
}); | |
$("#submit-payment").click(function(event) { | |
event.preventDefault(); | |
if (!$("#order_form").valid()) return; | |
if (!$("#payment_form").valid()) return; | |
Spinner.show(Lang.get("order.spinner_text")); | |
var formData = new FormData($("#order_form")[0]); | |
$.ajax({ | |
url: baseUrl + modulePath + "order/submit", | |
data: formData, | |
processData: false, | |
contentType: false, | |
type: "POST", | |
dataType: "json" | |
}).done(function(data) { | |
if (data.op === "payment") { | |
$("#sale_id").val(data.id); | |
$("#payment_form")[0].submit(); | |
} else { | |
window.scrollTo(0, 0); | |
window.location.reload(); | |
} | |
}).fail(function() { | |
window.scrollTo(0, 0); | |
window.location.reload(); | |
}); | |
return false; | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment