Javascript override for “Place Order button” using custom Woocommerce payment gateway Javascript override for “Place Order button” using custom Woocommerce payment gateway wordpress wordpress

Javascript override for “Place Order button” using custom Woocommerce payment gateway


Here's the entire JavaScript you need to inject into the page:

jQuery( function($) {       $("form.woocommerce-checkout")  .on('submit', function() { return gatewayFunction( this ); } ); } );

The outer jQuery( function($) { and } ); make sure that the code in between only gets run when the HTML document is loaded (that way the the <form> will exist by the time that code will run), and makes jQuery available as $ in between.

The return gatewayFunction( this ) passes the <form> to the function, so it can use it's values and add or update a hidden payment token field, so you'll need to add that parameter to the gatewayFunction:

function gatewayFunction( form ) {  ...  return is_payment_complete;}