Skip to content

Instantly share code, notes, and snippets.

@bmakowski
Created May 29, 2018 08:58
Show Gist options
  • Save bmakowski/a28cbdd38034c32e5a3a6d1277875c37 to your computer and use it in GitHub Desktop.
Save bmakowski/a28cbdd38034c32e5a3a6d1277875c37 to your computer and use it in GitHub Desktop.
WooCommerce additional custom popup on checkout when processing payment
add_action( 'woocommerce_before_checkout_form', 'custom_payment_overlay' );
function custom_payment_overlay(){
echo sprintf('<div class="custom-payment-popup"><div class="wpt-payment-overlay"></div><div class="wpt-payment-message">%s</div></div>',
'We are processing your payment. Please hold on and do not refresh your browser.'
);
}
// Display popup when form submitted
var checkout_form = $( 'form.checkout' );
checkout_form.on( 'checkout_place_order', function() {
$(".custom-payment-popup").show();
return true;
});
// Hide popup if form returns an error
$( document.body ).on( 'checkout_error', function() {
$(".custom-payment-popup").hide();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment