-
-
Save mikejolley/b5c8e0b0dce07f615ccfb400604cfa87 to your computer and use it in GitHub Desktop.
<?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; | |
} | |
} |
@t1000upgraded
Did you added that code which Hobby alchemist shared or you used the plugin...please help me also..i need the same functionality on my
website..
when i add this code nothing happens .
Hey @abhi09123, just seen this, sorry. Yes it was exactly what I needed and worked like a charm. Thanks a million @HobbyAlchemist
@HobbyAlchemist, I found the code is deleted. Can you please share the code? It is important.
cassianotartari's code works perfect for external products. It is also affecting internal products, adding it to the cart and opening the link to the shop page in a new tab. It does not open to the product. Any ideas?
Hi, I also have an affiliate products website and the first code works perfectly but links are not open in a new tab.
Can anyone share a code to open it in a new tab that works with the last woocommerce version?
Or if anyone could share the code/plugin of @HobbyAlchemist would be very useful.
Thanks a lot!
please help, it doesn't work for me
@t1000upgraded
Did you added that code which Hobby alchemist shared or you used the plugin...please help me also..i need the same functionality on my
website..
when i add this code nothing happens .