Open "Buy Now" links in new window

By default, the Datafeedr WooCommerce Importer plugin will make the [Buy Now] button open in a new window/tab on WooCommerce Single Product page. If this is not working for you, try deactivating any "new window/tab" plugin you may have installed.

However, by default, [Buy Now] buttons do NOT open in a new window on WooCommerce Archive / Category / Storefront pages. To force the [Buy Now] buttons to open in a new tab/window from those pages, add the following code to your custom plugin:

function mycode_add_target_blank_to_external_products_in_loop( $args, WC_Product $product ) {
	if ( $product->is_type( 'external' ) ) {
		$args['attributes']['target'] = '_blank';
	}


	return $args;
}


add_filter( 'woocommerce_loop_add_to_cart_args', 'mycode_add_target_blank_to_external_products_in_loop', 20, 2 );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us