Lines 61-66
$(document).ready(function() {
Link Here
|
61 |
$('#checkoutConfirm').replaceWith('<button type="submit" id="checkoutSubmit" class="btn btn-primary">Submit</button>'); |
61 |
$('#checkoutConfirm').replaceWith('<button type="submit" id="checkoutSubmit" class="btn btn-primary">Submit</button>'); |
62 |
}; |
62 |
}; |
63 |
|
63 |
|
|
|
64 |
// Before modal show, check login |
65 |
$('#checkoutModal').on('show.bs.modal', function(e) { |
66 |
// Redirect to login modal if not logged in |
67 |
if (logged_in_user_id === "") { |
68 |
let url = new URL(window.location.href); |
69 |
url.searchParams.append('modal','checkout'); |
70 |
$('#modalAuth').append('<input type="hidden" name="return" value="' + url.href +'" />'); |
71 |
$('#loginModal').modal('show'); |
72 |
return false; |
73 |
} |
74 |
}); |
75 |
|
76 |
// Detect that we were redirected here after login and re-open modal |
77 |
let urlParams = new URLSearchParams(window.location.search); |
78 |
if (urlParams.has('modal')) { |
79 |
let modal = urlParams.get('modal'); |
80 |
history.replaceState && history.replaceState( |
81 |
null, '', location.pathname + location.search.replace(/[\?&]modal=[^&]+/, '').replace(/^&/, '?') |
82 |
); |
83 |
if (modal == 'checkout') { |
84 |
$("#checkoutModal").modal('show'); |
85 |
} |
86 |
} |
87 |
|
64 |
// On modal show, clear any prior results and set focus |
88 |
// On modal show, clear any prior results and set focus |
65 |
$('#checkoutModal').on('shown.bs.modal', function(e) { |
89 |
$('#checkoutModal').on('shown.bs.modal', function(e) { |
66 |
$('#checkoutResults').replaceWith('<div id="checkoutResults"></div>'); |
90 |
$('#checkoutResults').replaceWith('<div id="checkoutResults"></div>'); |
67 |
- |
|
|