• Resolved netsoftlab

    (@netsoftlab)


    Hi there

    Is there a way to have the following code for my product images/thumbnails link to a new tab?

    add_action( ‘template_redirect’, ‘redirect_external_products’ );
    function redirect_external_products() {
    global $post;
    if ( is_singular( ‘product’ ) && ! empty( $post ) && ( $product = wc_get_product( $post ) ) && $product->is_type( ‘external’ ) ) {
    wp_redirect( $product->get_product_url() );
    exit;

    need it to work like https://www.shopstyle.com/browse/backpacks

    Currently it opens external link in same tab want the code to open link in external tab

    Any help is much appreciated.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    Scanning through the code, it looks like you’re trying to open external products in a new tab – right? If so, have you considered using this plugin: https://www.ads-software.com/plugins/wc-external-product-new-tab/?

    Thread Starter netsoftlab

    (@netsoftlab)

    This “external products in a new tab ” works on the product page and the above code works on the shop page, have used this plugin but it wont help. I need modification for above code, i have seen some people have successfully modified it, but they have not posted the modified code.

    Rambo

    (@rahul020691)

    Hi @netsoftlab,

    Thank you for sharing additional details. This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to come up with a solution! If you have further questions on the core WooCommerce plugin please feel free to open a new topic.

    Cheers.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Product Image Thumbnail to External Link in New Tab’ is closed to new replies.