Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi,
    if you want to add a link/button to open compare table try to add this code on your theme functions.php. This code create a shortcode that print a button to open compare

    add_shortcode('custom_compare_button', 'add_custom_compare_button' );
    function add_custom_compare_button(){
    	global $yith_woocompare;
    
    	if( is_admin() || is_null( $yith_woocompare ) ) {
    		return '';
    	}
    
    	$link = $yith_woocompare->obj->view_table_url();
    
    	return '<a href="' . $link . '" class="button">View Compare</a>';
    }

    Then you can use it like this [custom_compare_button] or in code using this:
    echo do_shortcode('[custom_compare_button]');

    Let me know, regards. 🙂

    Thread Starter Suhan Alam Rana

    (@ranakpik)

    Thank you so much for your Help and this Great Plugin

    Plugin Author YITHEMES

    (@yithemes)

    Hi,
    you are welcome.

    Regards.

    How to amend the Compare URL link so that it opens into a popup window?
    Please advise. Thank you.

    After looking through “/yith-woocommerce-compare/assets/js/woocompare.js”, I found a hint between lines 166 and 171.

    In the end, I just inserted this attribute, class="yith-woocompare-open" into the HTML a tag, and it works. Yahoo! \(>_<)/

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘how to set custom compare button in header’ is closed to new replies.