Page 4 of 4 FirstFirst ... 234
Results 31 to 34 of 34
  1. #31
    Join Date
    Oct 2014
    Posts
    11
    Plugin Contributions
    0

    Default Re: Adding Product Rating on Product Listing Page

    How to add product rating to product listing?
    includes/modules/YOUR_TEMPLATE/product_listing.php
    GO TO LINE 144 add below code:
    PHP Code:
            // 2P added BOF - Average Product Rating
              
    if (reviews_count_function($listing->fields['products_id'], 'count') > ) {
                
    $stars_image_suffix str_replace('.''_'zen_round(reviews_average_rating_function($listing->fields['products_id'], 'average_rating') * 20) / 2); // for stars_0_5.gif, stars_1.gif, stars_1_5.gif etc.
                
    $average_rating zen_round(reviews_average_rating_function($listing->fields['products_id'], 'average_rating'), 2);
                
    $lc_text .= '(<a href="' $link_of_product '"><strong>' reviews_count_function($listing->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{
                
    $lc_text .= '(<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 EOF - Average Product Rating 
    GO TO LINE 207 add below code:
    PHP Code:
            // 2P added BOF - Average Product Rating
            
    $link_of_product zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > and $_GET['filter_id']) > zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' $listing->fields['products_id']);
            
    // 2P added EOF - Average Product Rating 
    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;
        }
     }

    ?>
    Click image for larger version. 

Name:	1.jpg 
Views:	72 
Size:	28.6 KB 
ID:	14688
    Last edited by andis02; 12 Nov 2014 at 08:49 AM. Reason: change CODE to PHP CODE

  2. #32
    Join Date
    Oct 2014
    Posts
    11
    Plugin Contributions
    0

    Default Re: Adding Product Rating on Product Listing Page

    Click image for larger version. 

Name:	2.jpg 
Views:	59 
Size:	20.4 KB 
ID:	14691


    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'] > and $_GET['filter_id']) > zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 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') > ) {
                
    $stars_image_suffix str_replace('.''_'zen_round(reviews_average_rating_function($new_products->fields['products_id'], 'average_rating') * 20) / 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_########.'&nbsp; &nbsp; &nbsp;&nbsp;'.$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
        } 
     } 

    ?>

  3. #33
    Join Date
    Oct 2014
    Posts
    11
    Plugin Contributions
    0

    Default Re: Adding Product Rating on Product Listing Page

    ADD product rating in product info page:

    If you use plugin - Tabbed Products Pro
    You need add content in the first line to get reviews count.
    /includes/templates/YOUR_CUSTOM_TEMPLATE/templates/tpl_product_info_display.php
    PHP Code:
    <?php 
    // 2P modified BOF - Average Product Rating
    $reviews_count $reviews->fields['count'];
    // 2P modified EOF - Average Product Rating 
    ?>

    /includes/templates/YOUR_CUSTOM_TEMPLATE/templates/tpl_product_info_display.php

    Find below code:
    PHP Code:
    <?php // display qty and button ?>
    <?php 
    // CUSTOMERS_APPROVAL == 3 ?>
    <!--eof Add to Cart Box-->
    Add content after <!--eof Add to Cart Box-->

    PHP Code:
      <?php 
      
    // 2P modified BOF - Average Product Rating
      
    echo '<p class="reviewCount">';
      if (
    reviews_count_function($_GET['products_id'], 'count') > ) {
        echo 
    TEXT_CURRENT_REVIEWS ' <strong>' $reviews_count '</strong>';
        
    $stars_image_suffix str_replace('.''_'zen_round($reviews_average_rating->fields['average_rating'] * 20) / 2); // for stars_0_5.gif, stars_1.gif, stars_1_5.gif etc.
        
    $average_rating zen_round($reviews_average_rating->fields['average_rating'], 2);
        echo 
    TEXT_CURRENT_REVIEWS_RATING ' <strong>' $average_rating '</strong> ' zen_image(DIR_WS_TEMPLATE_IMAGES 'stars_' $stars_image_suffix '.gif'sprintf(BOX_REVIEWS_TEXT_OF_5_STARS$average_rating));
      } else {
        echo 
    '(<strong>0</strong>)' zen_image(DIR_WS_TEMPLATE_IMAGES 'stars_5.gif'sprintf(BOX_REVIEWS_TEXT_OF_5_STARS'5'));
      }
      echo 
    '</p>';
    // 2P modified EOF - Average Product Rating ?>

  4. #34
    Join Date
    Jul 2012
    Posts
    345
    Plugin Contributions
    0

    Default Re: Adding Product Rating on Product Listing Page

    How to display rating in center box like related product, customer also purchase etc?

 

 
Page 4 of 4 FirstFirst ... 234

Similar Threads

  1. v150 How to add product rating (stars) to a product on main page
    By Dave1st in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 12 Jul 2015, 03:04 PM
  2. v139a Adding Product Rating on Featured Listing Page
    By gal_op in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 6 Oct 2012, 06:17 AM
  3. Stars Rating under product listing page
    By ken0306 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 2 Feb 2011, 01:46 AM
  4. Average Rating in Search Results or Product Listing
    By hungoveragain in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 26 Oct 2009, 10:11 AM
  5. Showing product rating on listing
    By jcastr in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 15 Jun 2009, 05:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR