Disable single product pages BUT send users directly from the shop page to Amzn
-
Hi there;
I have an affiliate website. I want; When visitors click on a “product’s image” or a “product title” on my Shop Archive page, I want them to go directly to the affiliate link by opening a new tab.At the below code; when I click the “product image” of a product at my Shop Archive page, it does exactly what I want. it sends the visitor to the affiliate site within a new tab. BUT when I click the “product title” it directs me to the “Single Product Page” which I don’t want.
The code I use at below. This code only sends the user to the affiliate product if he clicks the image. This code doesn’t send him to the affiliate site if he clicks the product title. It sends to the single product page. Please help !!!
function woocommerce_template_loop_product_link_open() { global $product; if( $product->is_type( 'external' ) ) { $link = apply_filters( 'woocommerce_loop_product_link', $product->get_product_url(), $product ); echo '<a target="_blank" href="' . esc_url( $link ) . '" rel="noopener noreferrer">'; } else { $link = apply_filters( 'woocommerce_loop_product_link', get_the_permalink(), $product ); echo '<a href="' . esc_url( $link ) . '">'; } }
- The topic ‘Disable single product pages BUT send users directly from the shop page to Amzn’ is closed to new replies.