Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Display donation receipt in Form Grid modal after offline gateway redirect #7672

Merged
merged 6 commits into from
Jan 20, 2025
28 changes: 28 additions & 0 deletions assets/src/js/frontend/give-misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,34 @@ jQuery(
mainClass: 'modal-fade-slide give-modal',
}
);

// Donation grid shortcode:
// Offline gateways like Stripe refresh the page, and we need to programmatically reopen the modal for the confirmation page.
$(doc).ready(function () {
function reopenOnGatewayRedirect()
{
const urlParams = new URLSearchParams(window.location.search);

const completedFormEmbedId = urlParams.get('givewp-embed-id');

const isGatewayRedirect = urlParams.has('givewp-embed-id') &&
urlParams.get('givewp-event') === 'donation-completed' &&
urlParams.get('givewp-listener') === 'show-donation-confirmation-receipt' &&
urlParams.has('givewp-receipt-id');

if (isGatewayRedirect) {
document.querySelectorAll('.js-give-grid-modal-launcher').forEach(function (formGridModalLauncher) {
const modalFormEmbedId = formGridModalLauncher.nextElementSibling.firstElementChild.dataset.givewpEmbedId;

if (modalFormEmbedId === completedFormEmbedId) {
formGridModalLauncher.click();
}
});
}
}
reopenOnGatewayRedirect();
});

// Compatible for X theme and Cornerstone plugin.
if ( typeof window.csGlobal !== 'undefined' ) {
window.jQuery( function( $ ) {
Expand Down
Loading