I had a few orders being placed for the wrong location for pickup by the customers. I was looking for a confirmation popup during checkout process that would be displayed for the customer. This is a regular alert box.
My implementation only shows it once during checkout step 1, and it's using localStorage for this purpose which gets reset whenever the homepage is loaded.
checkout.php, inside the javascript section: "$(document).ready(function() {"
// Check if localStorage is present. If it's not present or it's set to 0, alert.
var intersections = [];
var location = '<?php echo $location_name; ?>';
var message = 'Your pick up location is set to: ' + location;
if (typeof(Storage) !== "undefined") {
if (sessionStorage.hasSeenPopup) {
if (sessionStorage.hasSeenPopup != 1) {
alert(message);
sessionStorage.hasSeenPopup = 1;
}
}
else {
alert(message);
sessionStorage.hasSeenPopup = 1;
}
} else {
// Sorry! No Web Storage support..
alert(message);
}
<?php } ?>`
home.php, right above: "<?php echo get_footer(); ?>"
`<script type="text/javascript"><!--
//reset localStorage to 0. This is for the alert popup for location
$(document).ready(function() {
if (typeof(Storage) !== "undefined") {
if (sessionStorage.hasSeenPopup) {
if (sessionStorage.hasSeenPopup == 1) {
// Reset
sessionStorage.hasSeenPopup = 0;
}
}
}
});
//--></script>```