I'm starting with programming with wordpress and woocommerce. I need help after searching for Stack.
I need the images and titles of the products of my store to point to the affiliate link without going through the single post page. And that everything opens in a new tab.
Been following this thread: Woocommerce - External/Affiliate Product Image to External Link (Buy url)
I have used the Edit # 2 code from Sadoo and it works perfectly for me.
remove_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open');
add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', 15);
add_action('woocommerce_before_shop_loop_item', 'woocommerce_add_aff_link_open', 10);
add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_add_aff_link_close', 10);
function woocommerce_add_aff_link_open(){
$product = wc_get_product(get_the_ID());
if( $product->is_type( 'external' ) )
echo '<a href="' . $product->get_product_url() . '" class="woocommerce-LoopProductImage-link">';
}
function woocommerce_add_aff_link_close(){
$product = wc_get_product(get_the_ID());
if( $product->is_type( 'external' ) )
echo '</a>';
}
I just need the title to link like the image and everything opens in new tabs.
Can someone say how can I continue?
Thank you