As a start, customize the file:
/includes/modules/pages/product_reviews_write/header_php.php
and add the code in RED:
Code:
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
// bof: check customer bought product before allowing creation of a review
$customers_query_raw = "select c.customers_id, c.customers_firstname, c.customers_lastname, sum(op.products_quantity * op.final_price)+sum(op.onetime_charges) as ordersum from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS . " o where c.customers_id = o.customers_id and o.orders_id = op.orders_id and op.products_id = :productsID";
$customers_query_raw = $db->bindVars($customers_query_raw, ':productsID', $_GET['products_id'], 'integer');
$customers_query = $db->Execute($customers_query_raw);
if ($customers_query->EOF) {
// $messageStack->add_session('header', 'Customer Bought this', 'caution');
} else {
$messageStack->add_session('header', 'Customer did NOT buy this', 'caution');
zen_redirect(zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params(array('reviews_id'))));
}
// eof: check customer bought product before allowing creation of a review
NOTE: you could make this the only change or get fancier based on where the customer is, are they logged in, did they buy the product, etc. etc. etc.
Bookmarks