Woocommerce linking
-
I’m at a loss and would be grateful for any assistance. My theme is Woocommerce’s Storefront, no child theme. On my Archive/Catalog pages, I want the product image and the button to lead to an external URL in a new tab and the product title to lead to the internal single product page. The code I’m using works to separate the image from the title and the title does exactly what I want it to, but the image is not opening in a new tab. For the button, I tried to use the ‘WooCommerce External Product New Tab’ and ‘WooCommerce External Product New Tab’ plugins to make the button open in an external tab, but neither plugin is working for me.
This is the code I’m using:
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 ‘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 ‘‘;
}Deeply appreciative of this forum and the generous experts here!
ChrisThe page I need help with: [log in to see the link]
The topic ‘Woocommerce linking’ is closed to new replies.