Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1066877

    tafrancis
    Participant

    I am using woocommerce to sell products and have enables the review tab on the product page. When an order has completed want to send an email requesting a review with a link to the the relevant product review page. I have put the url in the email but I can’t get the review tab to be active

    I have tried using http://horseboxcoffeeco.com/product/dark-horse/#reviews and http://horseboxcoffeeco.com/product/dark-horse/#comment-1 but both take me to the product page with the description tab active. I would like the review tab active and ideally navigate to the review tab rather than the top of the product page.

    Is there any way that I can achieve this?

    #1067482

    Rad
    Moderator

    Hi there,

    Thanks for posting in.

    Please add this code to Admin > Appearance > Customizer > Custom > Javascript.

    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-cs-tab-toggle="' + tab_index + '"]' ).click();
    
    $('html, body').stop().animate( { scrollTop : $( 'a[data-cs-tab-toggle="' + tab_index + '"]' ).offset().top - 80 } );
    
    }
    
    } );
    
    } );

    If you decide to enable other tabs, then you’ll have to add the hash and the tab index it represents. Tab index is the order of the tab starting from the description tab.

    case '#reviews': tab_index = 2; break;
    case '#related': tab_index = 3; break;
    case '#specs': tab_index = 4; break;

    Hope this helps.

    #1068129

    tafrancis
    Participant

    Many thanks, works perfectly.

    #1068230

    Lely
    Moderator

    You’re welcome!

    Cheers!