0

I am using woocommerce and am trying to figure out how I can specifically link to the review section of the page.

I've tried stuff like: www.mywebsite.com/product-page/#review_form

And while this automatically brings the user down to where the review field is on the product page, it doesn't actually activate the review tab in order to see the review field once you are at that part of the page (I have a few tabs here such as description, customer photos, reviews).

Is there a way to simultaneously activate the review tab (class = "reviews_tab active") and have it automatically jump to that part of the page?

I'm also trying to get it to work in all browsers, since many customers use mobile.

1

You would probably need to do this with jQuery by detecting the hash value and activating the class based on that. Something like this might work:

add_action('wp_footer', 'custom_review_form_activate');
function custom_review_form_activate() {
    echo "<script>if (window.location.hash == 'review_form') {
        jQuery('.reviews_tab').addClass('active');
    }</script>";
}

(Of course if your theme or customizations already have some jquery you can add it there instead of in the footer like this.)

Not the answer you're looking for? Browse other questions tagged or ask your own question.