Skip to content

Commit

Permalink
fix: respect go back behavior of checkout button
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed May 31, 2024
1 parent a3ac1a5 commit e19da43
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions src/modal-checkout/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ domReady( () => {
if ( 'custom' === afterSuccessBehavior ) {
window.location.href = afterSuccessUrl;
} else if ( 'referrer' === afterSuccessBehavior ) {
const referrer = document.referrer || window.location.href;
window.location.href = referrer;
window.history.back();
}
}
};
Expand Down Expand Up @@ -168,21 +167,6 @@ domReady( () => {
forms.forEach( form => {
form.appendChild( modalCheckoutHiddenInput.cloneNode() );
form.target = IFRAME_NAME;

const afterSuccessUrlInput = form.querySelector( 'input[name="after_success_url"]' );
const afterSuccessBehaviorInput = form.querySelector(
'input[name="after_success_behavior"]'
);

// Fill in the referrer field.
if (
afterSuccessBehaviorInput &&
afterSuccessUrlInput &&
'referrer' === afterSuccessBehaviorInput.getAttribute( 'value' )
) {
afterSuccessUrlInput.setAttribute( 'value', document.referrer || window.location.href );
}

form.addEventListener( 'submit', ev => {
const formData = new FormData( form );
const variationModals = document.querySelectorAll( `.${ MODAL_CLASS_PREFIX }-variation` );
Expand Down

0 comments on commit e19da43

Please sign in to comment.