Skip to content

Instantly share code, notes, and snippets.

@kish2011
Forked from bmakowski/functions.php
Created May 9, 2025 18:47
Show Gist options
  • Save kish2011/4f3507b04fa459e0caeb9fb1ab790be7 to your computer and use it in GitHub Desktop.
Save kish2011/4f3507b04fa459e0caeb9fb1ab790be7 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