• Resolved Mohammed

    (@mohammedbhorania)


    When clicking on a product in WooCommerce, it currently opens the product page in the same tab. We want to have the product page open in a new tab instead to improve user experience and reduce bounce rate.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @mohammedbhorania,

    The following snippet of code will open the single product page in a new tab:

    remove_action( 'woocommerce_before_shop_loop_item',
    'woocommerce_template_loop_product_link_open', 10 );
    add_action( 'woocommerce_before_shop_loop_item', 'open_product_in_new_tab', 10 );
    
    function open_product_in_new_tab() {
    	echo '<a target="_blank" href="' . get_the_permalink() . '" class="woocommerce-LoopProduct-link">';
    }

    You can add this snippet of code to your active child theme’s functions.php file.

    Please make sure you don’t edit the theme files directly as they will be overwritten when the theme is updated. To protect your changes from updates, create a Child Theme in which to keep all your changes.

    I hope this helps! Good luck!

    Thread Starter Mohammed

    (@mohammedbhorania)

    Hi @kaavyaiyer

    Thank you for response!

    I’m sorry to hear that “Open WooCommerce Single Product in New Tab” is not working. Could you please provide me with more information about this

    Website URL: https://nepriworld.com/product-category/sling/round-sling/

    Please check the above URL

    Hi @mohammedbhorania,

    Were you able to add the code that I shared in my previous reply to your site, by creating a child theme and adding the code to the child theme’s functions.php file?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Open WooCommerce Single Product in New Tab’ is closed to new replies.