I'm developing a custom shopping cart functionality where multiple items are able to be bought on a single page, and when an add to cart button is pressed, the page refreshes, but moves to the top of the document.
Sometimes the action throws up errors or notices so i'd like to be able to keep the current scroll height when the page is refreshed
I tried adding javascript but cant seem to get it to work-- here's what im using, the first line is the function that adds any messages or notices. Are there anyways to accomlish this using strictly php? or is there a reason my function isnt working?
<?php wc_print_notices(); ?>
<div id="messageScroll"></div>
<script>
$(window).load(function() {
$("html, body").animate({scrollTop:$("#messageScroll").offset().top}, 800);
});
</script>
<?php