• Resolved Dave McHale

    (@dmchale)


    Hello, I recently made a number of customizations to the single product page template and for some reason, the Compare button no longer works. When you click the button, the browser is simply redirected to the homepage for my domain and it seems like the AJAX isn’t firing.

    The HTML is still exactly the same for the Compare button itself, and we did not change any of the settings.

    <a href="http://www.MYSITE.wp?action=yith-woocompare-add-product&id=2686" class="compare button" data-test="12345" data-product_id="2686" rel="nofollow">Compare</a>

    I do not have any console errors before, or after, clicking the Compare button.

    I cannot tell what would have changed to break the functionality of the button. Any help would be extremely appreciated – thank you!

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

    (@yithemes)

    Hi there,
    did you remove the class “product” from the page wrapper?
    We perform the ajax call on click on comparison link using following code.

    // add into table
        $(document).on( 'click', '.product a.compare:not(.added)', function(e){
            e.preventDefault();
    
            var button = $(this),
                data = {
                    action: yith_woocompare.actionadd,
                    id: button.data('product_id'),
                    context: 'frontend'
                },
                widget_list = $('.yith-woocompare-widget ul.products-list');

    As you can see, we use ‘.product a.compare:not(.added)’.

    Please check and let me know.

    Thread Starter Dave McHale

    (@dmchale)

    That fixed it! I tried to find that code but was unable to (and still can’t find it, incidentally. If you could point me to where this exists in the plugin, I’d greatly appreciate it). But after adding the product class to the container div around my link, everything works again as normal. Thank you again!

    Plugin Author YITHEMES

    (@yithemes)

    Hi there,

    you are right, adding the product class to the container is the correct solution because if you edit the snippet you’ll lost this customization after plugin update.

    Have a nice day
    YITH

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Product Page Template updates broke Compare button’ is closed to new replies.