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 |
$('#modalAuth').append('<input type="hidden" name="return" value="' + window.location.pathname + window.location.search + '&modal=checkout" />'); |
69 |
$('#loginModal').modal('show'); |
70 |
return false; |
71 |
} |
72 |
}); |
73 |
|
74 |
// Detect that we were redirected here after login and re-open modal |
75 |
let urlParams = new URLSearchParams(window.location.search); |
76 |
if (urlParams.has('modal')) { |
77 |
let modal = urlParams.get('modal'); |
78 |
history.replaceState && history.replaceState( |
79 |
null, '', location.pathname + location.search.replace(/[\?&]modal=[^&]+/, '').replace(/^&/, '?') |
80 |
); |
81 |
if (modal == 'checkout') { |
82 |
$("#checkoutModal").modal('show'); |
83 |
} |
84 |
} |
85 |
|
64 |
// On modal show, clear any prior results and set focus |
86 |
// On modal show, clear any prior results and set focus |
65 |
$('#checkoutModal').on('shown.bs.modal', function(e) { |
87 |
$('#checkoutModal').on('shown.bs.modal', function(e) { |
66 |
$('#checkoutResults').replaceWith('<div id="checkoutResults"></div>'); |
88 |
$('#checkoutResults').replaceWith('<div id="checkoutResults"></div>'); |
67 |
- |
|
|