debounce is not defined / Sort By not working on collection/search results page - Please Help!

Solved

debounce is not defined / Sort By not working on collection/search results page - Please Help!

Lew2234
Tourist
12 2 2

So the sort by feature is not working on my site (Dawn 2.3.0).

 

The console is saying:

Uncaught ReferenceError: debounce is not defined
at new FacetFiltersForm (facets.js?v=12346274531771569079:6:5)

 

Steps I have tried:

1. Copying the code in all the facets files from a fresh copy of dawn, the console still throws the error 😕

 

Would greatly appreciate any help in solving this issue.

Accepted Solution (1)

PageFly-Richard
Shopify Partner
4971 1111 1793

This is an accepted solution.

Hi Lew 2234,

I'm Richard, CRO Expert from the PageFly team. Regards your problem, it's likely that the debounce function is missing somehow. To bring it back, you may follow my instruction below.

First thing first, debounce is a very popular javascript function and if it's not supposed to be "that popular" debounce but your theme-only debounce function, adding the code below won't help. In this case, you might need to contact Shopify to resolve the issue.

1. Navigate to your online store section -> Theme -> Actions -> Edit code

2. Open theme.liquid and add the this code just below your </body> tag

 

<script>
function debounce(func, timeout = 300){
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => { func.apply(this, args); }, timeout);
  };
}
</script>

 

3. Save the file, the issue should be resolved by now. Hope this helps.

Best regards,
Richard - PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 


All features are available from Free plan. Live Chat Support is available 24/7.

View solution in original post

Replies 6 (6)

LitExtension
Shopify Partner
4914 1005 1182

Hi @Lew2234,

Please send your site and if your site is password protected, please send me the password. I will check it.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com

PageFly-Richard
Shopify Partner
4971 1111 1793

This is an accepted solution.

Hi Lew 2234,

I'm Richard, CRO Expert from the PageFly team. Regards your problem, it's likely that the debounce function is missing somehow. To bring it back, you may follow my instruction below.

First thing first, debounce is a very popular javascript function and if it's not supposed to be "that popular" debounce but your theme-only debounce function, adding the code below won't help. In this case, you might need to contact Shopify to resolve the issue.

1. Navigate to your online store section -> Theme -> Actions -> Edit code

2. Open theme.liquid and add the this code just below your </body> tag

 

<script>
function debounce(func, timeout = 300){
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => { func.apply(this, args); }, timeout);
  };
}
</script>

 

3. Save the file, the issue should be resolved by now. Hope this helps.

Best regards,
Richard - PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 


All features are available from Free plan. Live Chat Support is available 24/7.

Lew2234
Tourist
12 2 2

Hey Richard, 

 

Thanks for that, the code worked and the filter is now working!

 

I noticed the log is now throwing this error :

Uncaught ReferenceError: onKeyUpEscape is not defined
    at new FacetFiltersForm (facets.js?v=12346274531771569079:13:62)
    at facets.js?v=12346274531771569079:175:16

 

Thanks again for the help, It's greatly appreciated!

Lew2234
Tourist
12 2 2

Edit* posted same comment twice by accident 

PageFly-Richard
Shopify Partner
4971 1111 1793

Hi Lew2234,

The function onKeyUpEscape appears to be wrongly handled in FacetFiltersForm while users hit the escape (ESC) button and release it (or could be you're not pressing that button, the bug is still presenting), specifically facets.js file. This is a code-related problem, probably their bug. If you're using FacetsFilterForm, please contact them on this.

I'm glad my solution helps. 😄

Best regards,

Richard - PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 


All features are available from Free plan. Live Chat Support is available 24/7.

vinodkalyan
Shopify Partner
10 0 1

still i'm getting same issue