Learnings from crashing wordpress on countless occasions!

woocommercelogo

Some woocommerce site-owners like to have a great commenting system in place of the reviews that come out-of-the-box with Woo-commerce.

WP Tuts+ has a great post on how to manually integrate Disqus with any page in wordpress. I’m going to start from there on how to extend those steps for Woocommerce -Disqus integration.

Assuming that you have already created your Disqus account and registed your site URL there and you also have a disqus shortname (for the purpose of this article, i’m taking the shortnme to be ‘my_awesome_shortname’)

Here is the code that you will need to copy into the functions.php of your theme :

function disqus_embed($disqus_shortname) {
    global $post;
    wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus.com/embed.js');
    echo '<div id="disqus_thread"></div>
    <script type="text/javascript">
        var disqus_shortname = "'.$disqus_shortname.'";
        var disqus_title = "'.$post->post_title.'";
        var disqus_url = "'.get_permalink($post->ID).'";
        var disqus_identifier = "'.$disqus_shortname.'-'.$post->ID.'";
    </script>';

You need to access the following file:So once you have copied this code into your functions.php, we are ready to call this function it anywhere we want the Disqus commeting system to appear.  Right now I really want it in my WooCommerce Reviews tab.

/wp-content/themes/your-theme/woocommerce/single-product-reviews.php

Just add this code here, after replacing ‘my_awesome_shortname’ with yout own disqus shortname:

<?php disqus_embed('my_awesome_shortname'); ?>

The recent woo-commerce 2 update has added a lot to a lot of people’s woes. Many themes are breaking and because the new update is a major release, not all file-names in the new version correspond to the older version. So a lot of tutorials and trouble-shooting material on the internet that has been written for Woo-commerce has become out-dated.

Being a wordpress novice, I do things by trail-n-error, and this has worked for me. I usually crash my site and servers over and over by these trials, just to trudge forward and get things going! If you face any issues, do let me know.

Comments on: "Integrating Disqus Comment System with Woocommerce" (6)

  1. Hello. I tried following your tutorial but it didn’t work. I have already created my Disqus account and registered my site URL there and I also have a disqus shortname.

    I have paste the functions in the function.php and have put in reviews.php but nothing happens. I have deactivate the discus plugin, but the review tab still show the default review of woocommerce.

    heres a link to my product: http://www.dagarments.com/product/gm_rs-o363/

    Please help on what I missed for it not to be working.

    • Hoping to get a help from you. I will very much appreciate it. Thanks!

    • Hi Bella,

      I navigated to the link you gave and the disqus commenting system is working perfectly there. I even left a comment on your product page. Can you please tell me specifically what is the problem you are facing?

      -Roopal

  2. it work. the only thing in function you missed out –> } for the closing. got to agree with you i try numberous of method suggested in many forums probably not suitable or outdated. and ur post just save my day.

Leave a comment

Tag Cloud