In this article I’ll walk you through the process of keeping your social networking share buttons active, after disabling the product reviews in OpenCart.
If you happened to have read my previous article about how to disable product reviews in OpenCart. I went over how you can turn off the ability for customers to see product reviews on your products. However when you disable this feature, it also removes the social media share buttons that exist for each product as well.
Keeping social share buttons
Using the steps below you’ll be able to still have your social share buttons, while leaving the product reviews disabled for your OpenCart site.
- Open up the File Manager Code Editor in cPanel and edit the following file:
/catalog/view/theme/default/template/product/product.tpl
You should also backup the file before editing to be on the safe side. - You’ll be looking for code around line 218, where it begins with <?php if ($review_status) { ?>:
<?php if ($review_status) { ?>
<div class="review">
<div><img src="catalog/view/theme/default/image/stars-
<?php echo $rating; ?>.png" alt="<?php echo $reviews; ?>" />
<a onclick="$('a[href='#tab-review']').trigger('click');"><?php echo $reviews; ?></a> |
<a onclick="$('a[href='#tab-review']').trigger('click');">
<?php echo $text_write; ?></a></div>
<div class="share"><!-- AddThis Button BEGIN -->
<div class="addthis_default_style"><a class="addthis_button_compact">
<?php echo $text_share; ?></a>
<a class="addthis_button_email"></a>
<a class="addthis_button_print"></a>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a></div>
<script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js"></script>
<!-- AddThis Button END -->
</div>
</div>
<?php } ?>
Copy the code beginning with <div class=”share”> down to the last </div> prior to the closing <?php } ?> tag:<div class="share"><!-- AddThis Button BEGIN -->
<div class="addthis_default_style"><a class="addthis_button_compact">
<?php echo $text_share; ?></a>
<a class="addthis_button_email"></a>
<a class="addthis_button_print"></a>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a></div>
<script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js"></script>
<!-- AddThis Button END -->
</div>
</div> - Directly below the closing <?php } ?> tag and prior to the next <div> tag, insert the following line:
<div class="review">
Then proceed to paste your copied code below that added line. You should end up at the end with the full thing looking like this, with the entered in and pasted code in red:
<?php if ($review_status) { ?>
<div class="review">
<div><img src="catalog/view/theme/default/image/stars-<?php echo $rating; ?>.png"
alt="<?php echo $reviews; ?>" /> <a onclick="$('a[href='#tab-review']').trigger('click');">
<?php echo $reviews; ?></a> | <a onclick="$('a[href='#tab-review']').trigger('click');">
<?php echo $text_write; ?></a></div>
<div class="share"><!-- AddThis Button BEGIN -->
<div class="addthis_default_style"><a class="addthis_button_compact">
<?php echo $text_share; ?></a>
<a class="addthis_button_email"></a>
<a class="addthis_button_print"></a>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a></div>
<script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js"></script>
<!-- AddThis Button END -->
</div>
</div>
<?php } ?>
<div class="review">
<div class="share"><!-- AddThis Button BEGIN -->
<div class="addthis_default_style">
<a class="addthis_button_compact">
<?php echo $text_share; ?></a>
<a class="addthis_button_email"></a>
<a class="addthis_button_print"></a>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a></div>
<script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js"></script>
<!-- AddThis Button END -->
</div>
</div>
</div>
</div>
You should now know how to disable the product reviews within OpenCart, but still keep your social networking share buttons active.