Tagged: x
-
AuthorPosts
-
June 30, 2016 at 11:12 am #1066877
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?
June 30, 2016 at 6:53 pm #1067482Hi 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.
July 1, 2016 at 4:36 am #1068129Many thanks, works perfectly.
July 1, 2016 at 6:45 am #1068230You’re welcome!
Cheers!
-
AuthorPosts