Access to woo reviews no longer working

I have used the code in this thread to get urls to point directly to reviews: https://theme.co/apex/forums/topic/url-to-link-to-product-review/

However just noticed that now the code no longer works, I get the following error in the Chrome console:

Uncaught TypeError: Cannot read property 'top' of undefined
at HTMLDocument.<anonymous> ((index):1551)
at i (jquery.js?ver=1.12.4:2)
at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
at Function.ready (jquery.js?ver=1.12.4:2)
at HTMLDocument.K (jquery.js?ver=1.12.4:2)

Any idea of what might have changed? Using the latest X and Cornerstone versions.

Hi @mrboats,

Thanks for writing in.

First, would you mind sharing us the URL of the page where you have added the code.

Don’t forget to check also if you have the latest version.

Thanks.

I’m on the latest versions:
x : 6.1.6
Cornerstone: 3.1.6

Hi There,

Upon checking, I see the following error on the console log.
TypeError: $(...).offset(...) is undefined

Could you please try disabling your 3rd party plugins and see if you are experiencing a plugin conflict. You can use health check plugin to test for a plugin conflict. This plugin has a troubleshooting mode which only affects to the login user so that your site visitors can still view your site while you’re testing your site. For more information, you can follow this video guide.

Thanks!

Hi,

Not sure what you mean, the only console error I can see is the one I have quoted above?

Still, when I test with Twenty16, the code provided in https://theme.co/apex/forums/topic/url-to-link-to-product-review/ works. When I change to X or X-child, then I get the error that I reported. So with this analysis, it seems that the issue is with X 6.1.6 + Corderstone 3.1.6?

Hi,

There is a slight change on the html markup of woocommerce tabs. The old version uses data-cs-tab-toggle= and the new version uses data-x-toggleable="x-legacy-tab-...

Please update your js code to this.


jQuery( function( $ ) {

$( document ).ready ( function() {

var target_tab = window.location.hash;

if ( $('.single-product').length > 0  && target_tab !== '' ) {

var tab_index = 0;

switch ( target_tab ) {
       case '#reviews': tab_index = 2; break;
      default: tab_index = 1; break; //Description is out default tab, hence, no need to add case.
}

$( 'a[data-x-toggleable="x-legacy-tab-' + tab_index + '"]' ).click();

$('html, body').stop().animate( { scrollTop : $( 'a[data-x-toggleable="x-legacy-tab-' + tab_index + '"]' ).offset().top - 80 } );

}

} );

} );

Hope that helps.

Thanks, problem solved.

If you need anything else please let us know.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.