Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created April 8, 2025 11:44
Show Gist options
  • Save xlplugins/d7bad933c6413bb68a0cbdb0620cc848 to your computer and use it in GitHub Desktop.
Save xlplugins/d7bad933c6413bb68a0cbdb0620cc848 to your computer and use it in GitHub Desktop.
amazon-pay
add_action( 'woocommerce_after_checkout_form', function () {
echo '<div id="classic_pay_with_amazon"></div>';
} );
add_action( 'wp_footer', function () {
?>
<script>
(function ($) {
$('form.checkout').on('checkout_place_order_success', function (e, result) {
$('form.checkout').unblock();
$('form.checkout').removeClass('processing');
});
// Remove specific hash on page load
document.addEventListener('DOMContentLoaded', function () {
if (window.location.hash === '#amazon-pay-classic-id-that-should-not-exist') {
// Create clean URL without the hash
const cleanUrl = window.location.href.split('#')[0];
// Update URL without reloading
window.history.replaceState({}, document.title, cleanUrl);
}
});
// Version with console confirmation
document.addEventListener('DOMContentLoaded', function () {
if (window.location.hash === '#amazon-pay-classic-id-that-should-not-exist') {
const originalUrl = window.location.href;
const cleanUrl = originalUrl.split('#')[0];
window.history.replaceState({}, document.title, cleanUrl);
console.log('Removed Amazon Pay hash:', originalUrl, '→', cleanUrl);
}
});
// Monitor URL changes continuously
window.addEventListener('hashchange', function () {
if (window.location.hash === '#amazon-pay-classic-id-that-should-not-exist') {
window.history.replaceState({}, '', window.location.href.split('#')[0]);
}
});
})(jQuery)
</script>
<?php
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment