hi have a WordPress woocommerce site…
i want to redirect the featured image of the product to an external website without going to the product page.
i achieved that by using this code in function file
**<?php // Do not include this if already open!**
**/****
** * Code goes in theme functions.php.**
** */**
**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;**
** }**
**}**
The problem is that it redirects in the same tab…i want it to redirect to a new tab
Thanks for your help…as i am a bit new to coding. Can you help me where to add <a> with target="_blank" in the above code which i have or where is the javascript located in my WordPress installation where i can add window.open()
I am trying to create a affiliate ecommerce website using woocomerce in WordPress where
if some one clicks on a featured image of a product in shop it opens the affiliate website link of the product in new tab rather than opening the product description page on my website
an exact example is here https://www.shopstyle.com/browse/backpacks