Replies: 0
Greetings
I am trying to chance the hook function to open external affiliate product
Althougth is working when I insert the products with woocomerce shortcut I loose the buy button, but when I insert the products with neve options of products I get the button the link to product won’t get affected, I will like to know if there is a way to customize this redirection.
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
add_action( 'woocommerce_before_shop_loop_item', 'tsa_woocommerce_link_nofollow', 10 );
function tsa_woocommerce_link_nofollow() {
global $product;
if ( $product->is_type('external') ) {
echo '<a target="_blank" rel="nofollow noopener noreferrer">get_product_url() . '">';
}else{
echo '<a href="' . get_the_permalink() . '">';
}
}