How to add producting in INDEX page?
includes/modules/YOUR_TEMPLATE/new_products.php
GO TO LINE 69, ADD BELOW:
PHP Code:
// 2P added new_product.php BOF - Average Product Rating
$link_of_product = zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' . $new_products->fields['products_id']);
if (reviews_count_function($new_products->fields['products_id'], 'count') > 0 ) {
$stars_image_suffix = str_replace('.', '_', zen_round(reviews_average_rating_function($new_products->fields['products_id'], 'average_rating') * 2, 0) / 2); // for stars_0_5.gif, stars_1.gif, stars_1_5.gif etc.
$average_rating = zen_round(reviews_average_rating_function($new_products->fields['products_id'], 'average_rating'), 2);
$reviews_rating = '(<a href="' . $link_of_product . '"><strong>' . reviews_count_function($new_products->fields['products_id'], 'count') . '</strong></a>)' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $stars_image_suffix . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $average_rating));
}else{
$reviews_rating = '(<a href="' . $link_of_product . '"><strong>0</strong></a>)' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_5.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, '5'));
}
// 2P added new_product.php EOF - Average Product Rating
includes/modules/YOUR_TEMPLATE/new_products.php
FIND BELOW CODE, and add
<div class="price">'.$reviews_rating.'</div>
as below
PHP Code:
////////////////////////////////////
$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' =>
'<div>'.$products_name.'</div>
<div class="img"> <span class="image">'.$products_img.'</span> </div>
<div class="wrapper">
<div class="price"> <strong>'.$products_price.'</strong> </div>
<div class="buttons">'.$products_########.' '.$buy_now_link.'</div>
<div class="price">'.$reviews_rating.'</div>
</div>'
);
//////////////////////////////////////
GO TO this DIR
includes/functions/extra_functions/
MAKE a file named:
function_average_product_rating.php
Whti below content:
PHP Code:
<?php
if (!function_exists('reviews_average_rating_function')) {
function reviews_average_rating_function($id, $field){
global $db;
$reviews_average_rating_query = "select avg(reviews_rating) as average_rating from " . TABLE_REVIEWS . " r, "
. TABLE_REVIEWS_DESCRIPTION . " rd
where r.products_id = '" . (int)$id . "'
and r.reviews_id = rd.reviews_id
and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'" .
$review_status;
$product = $db->Execute($reviews_average_rating_query);
$value = $product->fields[$field];
return $value;
}
}
if (!function_exists('reviews_count_function')) {
function reviews_count_function($id, $field){
global $db;
$review_status = " and r.status = '1'";
$reviews_query = "select count(*) as count from " . TABLE_REVIEWS . " r, "
. TABLE_REVIEWS_DESCRIPTION . " rd
where r.products_id = '" . (int)$id . "'
and r.reviews_id = rd.reviews_id
and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'" .
$review_status;
$reviews = $db->Execute($reviews_query);
$value = $reviews->fields[$field];
return $value;
}
}
?>
Bookmarks