Hello Friends ,
You know by default magento allow all guest or customer to give review on all products. but for my client requirement to give review on only purchased products i have created small code. here I’m going to share with you all.you can implement this code on view.php of theme file.
Here is code
<?php
$purcashed_products_id[] = array();
if (Mage::getSingleton(‘customer/session’)->isLoggedIn()) {
$orders= Mage::getModel(‘sales/order’)->getCollection()->addAttributeToFilter(‘customer_id’,23);
foreach($orders as $eachOrder){
$order = Mage::getModel(“sales/order”)->load($eachOrder->getId());
$items = $order->getAllVisibleItems();
foreach($items as $item):
$purcashed_products_id[] = $item->getProductId();
endforeach;
}
}
if (in_array($Current_product_id,$purcashed_products_id)) {?>
<?php echo $this->getChildHtml(‘product_reviews’); ?>
<?php }
?>