• HOME
  • NEWS
  • PORTFOLIO
  • LAB
  • ABOUT
  • CONTACT

woocommerce, overwrite auto scroll (scroll to notice function)

tags : auto scrollsnippetwoocommerce categories : programmation

by Trân on January 19, 2020

It is WooCommerce default behaviour to scroll to the top of the checkout or the cart form after an errored checkout submit.
I had a case where the auto scroll didn’t scroll to the right position so the errors were always hidden. The auto scroll code is located in the file woocommerce.js, here what I used to overwrite it, adding an offset :

1
2
3
4
5
6
7
8
9
// overwrite woocommerce scroll to notices
$.scroll_to_notices=function( scrollElement ) {
     var offset = 300;
     if ( scrollElement.length ) {
     $( 'html, body' ).animate( {
          scrollTop: ( scrollElement.offset().top-offset )
          }, 1000 );
     }
};

 

ACF how to update field link » « wordpress filter set-screen-option not working

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

 

Categories

  • général
  • inspiration
  • lab
  • programmation
  • sites
  • work

Tags

android architecture archives canvas cellules-studio cornelius css culturel demonstrateur design eshop flash fremok html html/css/js hugo IFTTT incandescence Instagram institutionnel ios ipad jeux js krpano luxe media design mobile musée nomoon paper fold photographie requins-marteaux responsive sbam snippet tablette toute-attente tran nn transport typographie ui ultranoir woocommerce wordpress

Stats

Archives

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
 

© fruit du dragon - freelance creative coder