Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Linkable Reviews Count on Product Page Rate Topic   - - - - -

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 15 April 2009 - 09:58 PM #1

UPDATE: See Post 14 for instructions for version 2.0.10 and higher:

For 1.3.5 SP4:
So I used some of the code from mdekok3000 posted in another thread. His code displayed the review count on the review tab itself. I wanted the count next to the stars with the words Customer reviews in front of the stars, a link saying "Read reviews" right before the count which opens the reviews tab and moves the page down to that tab content. The code below will accomplish this task. I updated code below to make this mod SEO friendly.

In addons/discussion/include/customer/products.php

ADD the code below just above the ?>

function fn_get_review_count($object_id,$object_type) 
        { 
            global $db_tables; 
             
            $discussion = fn_get_discussion($object_id, $object_type); 
             
            if (empty($discussion)) { 
                return false; 
            } 
            return db_get_field("SELECT COUNT(b.post_id) as val FROM $db_tables[discussion_rating] as a LEFT JOIN $db_tables[discussion_posts] as b ON a.post_id=b.post_id WHERE a.thread_id='$discussion[thread_id]' and b.avail='Y'"); ;
        }
THEN in your_skin/customer/addons/discussion/average_rating.tpl

ADD:
{assign var="rev_count" value=$object_id|fn_get_review_count:$object_type}
BELOW
{assign var="average_rating" value=$object_id|fn_get_average_rating:$object_type}

and then MODIFY:
{include file="addons/discussion/stars.tpl" stars=$average_rating|fn_get_discussion_rating}

TO

<b>Customer reviews: </b>{include file="addons/discussion/stars.tpl" stars=$average_rating|fn_get_discussion_rating}<b> {$average_rating|number_format:1}  </b><a href="{$index_script}?{$target_name}=products&product_id={$product.product_id}#tab_anchor" onclick ="fn_show_section('discussion', sections['info'], '');"> Read reviews ({$rev_count})</a>


Lastly in /your_skin/customer/products_pages/product_details.tpl
BELOW
{*************** /configurator ****************}
</form>

ADD

<a name="tab_anchor"></a>

Attached Files


John
CS Cart 4.2.4

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 204 posts

Posted 16 April 2009 - 09:54 AM #2

Thanks for your kindly help ! Why the #tab_anchor link to my homepage ?

How to display this on categories page and listmanian ?

Thanks again !
Do whatever you want to do....

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 16 April 2009 - 03:54 PM #3

Thats an anchor name to go with the href="#tab_anchor"

in the line :
<b>Customer reviews: </b>{include file="addons/discussion/stars.tpl" stars=$average_rating|fn_get_discussion_rating}<b> {$average_rating|number_format:1}  </b><a href="#tab_anchor" onclick ="fn_show_section('discussion', sections['info'], '');"> Read reviews ({$rev_count})</a>

which takes the user,when they clicked the Read reviews (n) link, to the tab area of a product detail page so the page scrolls down for the user so they know the tab changed . I have a lot of content before my tab area so my users wouldn't even see the tab area change, so I anchor them down. Also without the anchor you will not get the pretty finger pointing at the link since there would be no href only an onclick event. This mod was specifically designed for product reviews on the product detail page.
John
CS Cart 4.2.4

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 204 posts

Posted 16 April 2009 - 07:41 PM #4

Thats an anchor name to go with the href="#tab_anchor"

in the line :
<b>Customer reviews: </b>{include file="addons/discussion/stars.tpl" stars=$average_rating|fn_get_discussion_rating}<b> {$average_rating|number_format:1}  </b><a href="#tab_anchor" onclick ="fn_show_section('discussion', sections['info'], '');"> Read reviews ({$rev_count})</a>

which takes the user,when they clicked the Read reviews (n) link, to the tab area of a product detail page so the page scrolls down for the user so they know the tab changed . I have a lot of content before my tab area so my users wouldn't even see the tab area change, so I anchor them down. Also without the anchor you will not get the pretty finger pointing at the link since there would be no href only an onclick event. This mod was specifically designed for product reviews on the product detail page.

Yes, I got what you mean and did as what you said, but it will links to http://www.mysite.com/#tab_anchor and then redirect to my homepage, not redirect to Reviews section.

Please tell me how to resolve this, thanks so much !
Do whatever you want to do....

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 16 April 2009 - 09:36 PM #5

So you are on a product detail page and you click on Read reviews and it takes you to the homepage with the anchor at the end of the url?

The url should look something like www.mysite.com/store/index.php?target=products&product_id=29780#tab_anchor if you click on the Read Reviews link.

If this is the case then I don't think you have the href set up correctly if you are going to the homepage. Check your quotes maybe.

Again I only tested this with reviews on a product page so if you are calling a review from the homepage or a testimonial I haven't coded for or tested that.

Please post your average_rating.tpl.
John
CS Cart 4.2.4

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 204 posts

Posted 17 April 2009 - 03:13 AM #6

So you are on a product detail page and you click on Read reviews and it takes you to the homepage with the anchor at the end of the url?

The url should look something like www.mysite.com/store/index.php?target=products&product_id=29780#tab_anchor if you click on the Read Reviews link.

If this is the case then I don't think you have the href set up correctly if you are going to the homepage. Check your quotes maybe.

Again I only tested this with reviews on a product page so if you are calling a review from the homepage or a testimonial I haven't coded for or tested that.

Please post your average_rating.tpl.


{assign var="average_rating" value=$object_id|fn_get_average_rating:$object_type}
{assign var="rev_count" value=$object_id|fn_get_review_count:$object_type}
{if $average_rating}
{include file="addons/discussion/stars.tpl" stars=$average_rating|fn_get_discussion_rating}<b> {$average_rating|number_format:1}  </b><a href="#tab_anchor" onclick ="fn_show_section('discussion', sections['info'], '');"> Read reviews ({$rev_count})</a>
{/if}

Please check above. I use SEO url, so, it should be like as www.mysite.com/product-url#tab_anchor, right ?

Thanks so much !
Do whatever you want to do....

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 17 April 2009 - 03:26 AM #7

Please check above. I use SEO url, so, it should be like as www.mysite.com/product-url#tab_anchor, right ?

Thanks so much !


That is correct. I haven't enabled SEO yet on my cart but I am seeing the same result as you are now with the anchor. Let me look into this a bit.

UPDATE:
I got it and updated original post. Tested with and without SEO and it worked for me. Try the code below:

<b>Customer reviews: </b>{include file="addons/discussion/stars.tpl" stars=$average_rating|fn_get_discussion_rating}<b> {$average_rating|number_format:1}  </b><a href="{$index_script}?{$target_name}=products&product_id={$product.product_id}#tab_anchor" onclick ="fn_show_section('discussion', sections['info'], '');"> Read reviews ({$rev_count})</a>

John
CS Cart 4.2.4

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 204 posts

Posted 17 April 2009 - 04:13 AM #8

That is correct. I haven't enabled SEO yet on my cart but I am seeing the same result as you are now with the anchor. Let me look into this a bit.

UPDATE:
I got it and updated original post. Tested with and without SEO and it worked for me. Try the code below:

<b>Customer reviews: </b>{include file="addons/discussion/stars.tpl" stars=$average_rating|fn_get_discussion_rating}<b> {$average_rating|number_format:1}  </b><a href="{$index_script}?{$target_name}=products&product_id={$product.product_id}#tab_anchor" onclick ="fn_show_section('discussion', sections['info'], '');"> Read reviews ({$rev_count})</a>


Thanks so much ! The code works very well !
Do whatever you want to do....

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 17 April 2009 - 12:41 PM #9

Thanks so much ! The code works very well !


No Problem. I never really liked the way the review score looked on a product page but was too lazy to fix it before.
John
CS Cart 4.2.4

 
  • glyndon
  • Senior Member
  • Members
  • Join Date: 07-Dec 06
  • 187 posts

Posted 15 December 2009 - 12:03 PM #10

This looks great, a big improvement on what we have currently got.

Has anyone got this working on 2.0.8 - 2.0.10?

Many thanks

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 16 December 2009 - 03:59 PM #11

I am working on this. I have fixed the php code so it now pulls the correct review score and number of reviews but I do not know how to select the review tab in 2.0.10 since it has changed so much. I have only been working with v2 since this weekend so I am far from an expert with it. I created a thread in hints and mods to hopefully find someone to help.
John
CS Cart 4.2.4

 
  • glyndon
  • Senior Member
  • Members
  • Join Date: 07-Dec 06
  • 187 posts

Posted 16 December 2009 - 04:07 PM #12

I do not know how to select the review tab in 2.0.10 since it has changed so much.


Excellent. Thank you.

I will have a look at the code and see if I can work anything out.

Many thanks

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 16 December 2009 - 06:38 PM #13

Excellent. Thank you.

I will have a look at the code and see if I can work anything out.

Many thanks


That would be great if you were able to come up with something. There doesn't seem to be a function like fn_show_section in 2.0.10. I looked in tabs.js and some of the other js methods and couldn't find anything re-usable.
John
CS Cart 4.2.4

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 26 December 2009 - 08:08 PM #14

This is working in version 2.0.10 - 2.0.13 and works for Product of the day and Category pages as well.

The code below was done for the electro skin so you may need to tweek it a bit for a different skin.

In /<cartdir>/addons/discussion/controllers/customer/init.post.php
ADD the code below just above the ?>

function fn_get_review_count($object_id,$object_type) 
{ 
            global $db_tables; 
             
            $discussion = fn_get_discussion($object_id, $object_type); 
             
            if (empty($discussion)) { 
                return false; 
            } 
            return db_get_field("SELECT COUNT(b.post_id) as val FROM ?:discussion_rating as a LEFT JOIN ?:discussion_posts as b ON a.post_id = b.post_id WHERE a.thread_id = ?i and b.status = 'A'", $discussion['thread_id']); 
			
}

NEXT in skins/electro/customer/common_templates/scripts.tpl

ADD
{if $smarty.request.show_reviews == "Y"}   setTimeout("fn_show_reviews_tab();", 1000);  {/if}
AFTER
jQuery.runCart('C');

NEXT in skins/electro/customer/addons/discussion/views/discussion/components/average_rating.tpl
ADD
{assign var="rev_count" value=$object_id|fn_get_review_count:$object_type}
BELOW
{assign var="average_rating" value=$object_id|fn_get_average_rating:$object_type}
THEN
ADD
{literal}
<script language="javascript" type="text/javascript">
function fn_show_reviews_tab()
{
    var product_tabs = $('.cm-j-tabs:first');
    var _tabs = $('li', product_tabs);
    
    _tabs.each(function(){
        var self = $(this);
            if (self.html().indexOf('Reviews') != -1) {
                self.click();
                jQuery.scrollToElm(self);
            }
        
        }
    )
    
}
</script>
{/literal}
BELOW
{if $average_rating}
THEN
REPLACE
{include file="addons/discussion/views/discussion/components/stars.tpl" stars=$average_rating|fn_get_discussion_rating}
WITH
<p class="nowrap stars">
{include file="addons/discussion/views/discussion/components/stars.tpl" stars=$average_rating|fn_get_discussion_rating}<b> {$average_rating|number_format:1}</b><br/>
{if $smarty.request.product_id}
<a name="tabs_content" onclick="fn_show_reviews_tab(); return false;" href="{$config.current_url}#tabs_content">Read reviews ({$rev_count})</a>
{else}
<a href="{$index_script}?dispatch=products.view&product_id={$product.product_id}&show_reviews=Y">Read reviews ({$rev_count})</a>
{/if}
<br/></p>
LASTLY
In skins/electro/customer/addons/discussion/views/discussion/components/stars.tpl
REMOVE the <p class="nowrap stars"> and </p> tags as they were moved to average_ratings.tpl.
John
CS Cart 4.2.4

 
  • ywalker
  • Senior Member
  • Members
  • Join Date: 25-Oct 09
  • 104 posts

Posted 27 December 2009 - 11:30 PM #15

Hello,

Could one of you post a link to your site so I can get a look at what this does. I think I know but not sure of how it will work on my site and do not want to make all those changes until I do.

Thanks so much.
Yvonne Walker
VPS - WiredTree Hosting
CS-Cart 2.0.15

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 28 December 2009 - 01:33 AM #16

Hello,

Could one of you post a link to your site so I can get a look at what this does. I think I know but not sure of how it will work on my site and do not want to make all those changes until I do.

Thanks so much.


My site is not live so I can't post a link but here is an image from my local environment with this mod. When the user clicks the Read Reviews (n) the Review tab on the detail page is selected.

Attached Files


John
CS Cart 4.2.4

 
  • ywalker
  • Senior Member
  • Members
  • Join Date: 25-Oct 09
  • 104 posts

Posted 28 December 2009 - 02:50 AM #17

Thanks, that's what I thought. I am not live yet either but will definitely make the changes above because right now a shopper would not know if the product has reviews or not unless they click on the tab.

Thanks so much for sharing.
Yvonne Walker
VPS - WiredTree Hosting
CS-Cart 2.0.15

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 31 December 2009 - 06:53 PM #18

Thanks, that's what I thought. I am not live yet either but will definitely make the changes above because right now a shopper would not know if the product has reviews or not unless they click on the tab.

Thanks so much for sharing.


FYI. If you are using 2.0.11 there is a bug in the bug tracker that the review stars don't show on a product detail page so right now this will only work on 2.0.10.
John
CS Cart 4.2.4

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 21 January 2010 - 05:33 AM #19

Just an FYI, these changes work fine for 2.0.12 as well
John
CS Cart 4.2.4

 
  • Triplex
  • Senior Member
  • Members
  • Join Date: 12-Mar 08
  • 622 posts

Posted 21 January 2010 - 05:58 AM #20

Sorry for my bad english, what you mean with

Just an FYI


Also your first post work on 2.0.12 or not?

Thanks!