Header Ads

Woocommerce enable both Review and Disqus


Getting WooCommerce site is a pain in the donkey. I install Disqus and WooCommerce are both activated at the same time. Only noticing days later that if disqus comment is enable you can't have the review options.
All i want is to enable Review Tab of Woocommerce plus a Disqus comment is enable at the same time. Upon reading some tutorials that didn't work. I manage to work it out.
I have now Review tab and Comment tab on my product page and enable disqus comment in articles.


To enable Woocommerce review while disqus is activated.
Insert the code below to your disqus.php plugin folder.

if ( 'product' == get_post_type() ) { return false; }


Find

[box type="shadow" ] function dsq_can_replace[/box]


Place it between the.

if ( !get_option('disqus_forum_url') ) { return false; }
<insert here>else if ( 'all' == $replace )          { return true; }

It will look like this

function dsq_can_replace() {
global $id, $post;
if (get_option('disqus_active') === '0'){ return false; }
$replace = get_option('disqus_replace');
if ( is_feed() ) { return false; }
if ( !isset($post) ) { return false; }
if ( 'draft' == $post->post_status ) { return false; }
if ( !get_option('disqus_forum_url') ) { return false; }
if ( 'product' == get_post_type() ) { return false; }else if ( 'all' == $replace ) { return true; }

Add custom disqus comment tab
Put the code below to your theme functions.php
before the [highlight]?>[/highlight]

/*-----------------------------------------------------------------------------------*/
/* Add Disqus custom tab */
/*-----------------------------------------------------------------------------------*/
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>';
}
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['review_tab'] = array(
'title' => __( 'Comments', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content() {
// The new tab content
disqus_embed('pinoysuperdeals');
// remember to change the shortname above to your own
}

Credits to
https://github.com/woothemes/woocommerce/issues/1392
https://proserveweb.com/product-reviews-not-working-woocommerce/
http://menu.so/blog/443
http://www.tuxreports.com/community/resources/howto-enable-xenword-and-disqus-within-a-product-on-woocommerce-plugin.35/
Powered by Blogger.