Home › Forums › WoodMart support forum › YITH Compare, hangs when removing › Reply To: YITH Compare, hangs when removing
October 22, 2018 at 8:52 am
#84280
Artem Temos
Keymaster
Try to add the following PHP code snippet to the child theme functions.php file
function woodmart_compare_btn() {
if( ! class_exists( 'YITH_Woocompare' ) ) return;
if( get_option('yith_woocompare_compare_button_in_products_list') != 'yes' ) return;
echo '<div class="product-compare-button">';
global $product;
$product_id = $product->get_id();
// return if product doesn't exist
if ( empty( $product_id ) || apply_filters( 'yith_woocompare_remove_compare_link_by_cat', false, $product_id ) ) {
echo '</div>';
return;
}
$is_button = ! isset( $button_or_link ) || ! $button_or_link ? get_option( 'yith_woocompare_is_button' ) : $button_or_link;
if ( ! isset( $button_text ) || $button_text == 'default' ) {
$button_text = get_option( 'yith_woocompare_button_text', esc_html__( 'Compare', 'woodmart' ) );
}
printf( '<a href="%s" class="%s" data-product_id="%d" rel="nofollow">%s</a>', woodmart_compare_add_product_url( $product_id ), 'compare' . ( $is_button == 'button' ? ' button' : '' ), $product_id, $button_text );
echo '</div>';
}