Disqus conflict with WooCommerce rating/review system fix

July 3, 2014 | Ecommerce, PHP, Plugins, Time Savers, Troubleshooting, WooCommerce | 9 comments

I was recently asked to fix a conflict between the Disqus plugin for WordPress and WooCommerce. It turns out that when active it (Disqus) breaks the rating/review system which is reliant on the WordPress comment functionality. James over at Proserveweb appears to have come up with a crude solution to this but it’s not reliably usable because it relies on editing a plugin as opposed to ‘fixing’ the functionality from your theme or child theme. It’s important to remember that when editing a plugin you essentially need to self support thereafter because if you update to the next ‘official’ version your changes will be removed and you need to add them again. Not an ideal solution.

My solution is different in that you can add a few lines of code to your theme functions.php file and it will solve the issues encountered in this case. Use the following code and by all means feed back to me if you have any issues and I would be glad to help.

The code

add_action('the_post', 'sb_remove_woocommerce_disqus');
remove_action('pre_comment_on_post', 'dsq_pre_comment_on_post');

function sb_remove_woocommerce_disqus() {
	global $post, $wp_query;
	
	if (get_post_type() == 'product') { 
		remove_filter('comments_template', 'dsq_comments_template');
	}
}

A Donate Button!

9 Comments

  1. SovereignBeings

    Thank you very Much Sean. That worked like a charm

    Reply
  2. Danny

    Thankyou very much! Worked with no problems whatsoever 😀

    Reply
  3. josh

    Awesome… worked beautifully. Thanks!

    Reply
  4. Ryan

    Thanks Sean.

    Works like a charm!

    Reply
  5. Paul

    YOU ARE A LEGEND!!!

    So simple and of course it worked. Massive thanks!!

    Reply
  6. Daniel McAndrew

    I love it when something just works, thank you. It’s even better when it’s the first thing you try.

    Reply
  7. basslabb

    Thank you so much! Worked like a charm

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

CommentLuv badge

Stay in touch!

Page Builder Cloud

Page Builder Cloud

A truly universal template library for WordPress Page Builders.

Page Builder Recommendation

Elementor Banner

We are BIG fans of the Elementor page builder. Give it a look!

About this site and Sean Barton

Picture of Sean
Sean Barton is a Freelance PHP Website Developer in Crewe, Cheshire. He is a Wordpress and CMS/Framework specialist and Co-Founder of Page Builder Cloud.
This site was set up in 2008 as a tutorial and scripting resource for the PHP language and Wordpress.
Find out more about Sean on the About Me page or use the Hire Me page to get in touch. For more information about Sean's work take a look at the Portfolio

Our Services

  • Wordpress plugin/theme development
  • Divi specialist
  • Ecommerce (Woocommerce, WPSC, Shopify, Magento)
  • PSD to Wordpress theme conversion (Responsive)
  • Website design work (Banners, Logos, Full Site, etc)
  • Website analysis (security, usability, SEO)
  • API Integrations (InfusionSoft, SalesForce, Ontraport, Customer Thermometer, etc..)
  • Wordpress consultancy & expert advice
  • Crisis support
  • Website hosting

The main services offered are Wordpress based although we do a great deal of technical programming for bespoke systems. From troubleshooting, extending frameworks, finding bugs to writing them from scratch.

Find out more by looking through our past projects or get a quote.

Be the first to hear about new products/updates!

This is a mailing list for those people interested in being told when we release a new product (Divi plugin or Theme).

We shall also use this list to let you know about product updates and releases.

You have Successfully Subscribed!