Reply To: Product category page with no link to product detail page

Support Forums Kampina Product category page with no link to product detail page Reply To: Product category page with no link to product detail page

#225
TigriWeb
Keymaster

Hi Yvan,

We also use these hooks in the Kampina theme, so try this code:

function kampina_fix_template_loop_product_link_open() {
	?><div class="woocommerce-LoopProduct-link woocommerce-loop-product__link"><?php
}
function kampina_fix_template_loop_product_link_close() {
	?></div><?php
}
function kampina_fix_template_loop_product_title() {
	?><h2 class="<?php echo esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ); ?>"><?php
		the_title();
	?></h2><?php
}
function kampina_fix_loop_add_to_cart_link() {
	echo '';
}

add_action( 'template_redirect', function() {
	if ( is_product_category( 'produits-ferme' ) ) { // without is_product().
		// remove thumbnail a.
		remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
		remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 10 );

		// add thumbnail div.
		add_action( 'woocommerce_before_shop_loop_item', 'kampina_fix_template_loop_product_link_open', 10 );
		add_action( 'woocommerce_before_shop_loop_item_title', 'kampina_fix_template_loop_product_link_close', 10 );

		// remove title a.
		remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );

		// add title h2.
		add_action( 'woocommerce_shop_loop_item_title', 'kampina_fix_template_loop_product_title', 10 );

		// remove button.
		add_filter( 'woocommerce_loop_add_to_cart_link', 'kampina_fix_loop_add_to_cart_link', 10, 3 );

		// remove button aria-describedby span.
		add_filter( 'woocommerce_loop_add_to_cart_args', '__return_false' );
	}
} );

Best regards,
TigriWeb Team