Forums / Templates, Stylesheets, Page Layout / Facebook "Like" button on every product page?

Facebook "Like" button on every product page?

Views: 47,305

Results 1 to 20 of 115
22 Apr 2010, 1:15 PM
#1
scrap avatar

scrap

Zen Follower

Join Date:
Mar 2009
Posts:
103
Plugin Contributions:
0

Facebook "Like" button on every product page?

Hi
I've added AddThis on every product page (which was pretty easy), but I also want to add the new "Like button" from Facebook. You simply put a single iframe line where you want, and you're good to go.

Read more: http://developers.facebook.com/docs/reference/plugins/like

Here's the example code:

<iframe src="http://www.facebook.com/widgets/like.php?href=http://example.com"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"></iframe>

How do I get the href part to point to the page from which the visitor clicked? like href=http://www.mysite.com/index.php?main_page=product_info&cPath=543&products_id=4 without having to hard code it?

22 Apr 2010, 10:26 PM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Facebook "Like" button on every product page?

Something like:

<?php
echo zen_href_link(zen_get_info_page((int)$_GET['products_id']),'cPath= '.(int)$_GET['cPath'].' &products_id=' . (int)$_GET['products_id']);
?>

haven't tested this but it should work :smile:

Nick
iszent.com

24 Apr 2010, 5:05 AM
#3
trisha1581 avatar

trisha1581

New Zenner

Join Date:
Jan 2007
Posts:
66
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

Does that line of code go where the iframe ref is?

24 Apr 2010, 5:58 AM
#4
trisha1581 avatar

trisha1581

New Zenner

Join Date:
Jan 2007
Posts:
66
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

I have both the iframe and the piece of code that niccol added, but can not seem to get it right. I have added the code prior to the iframe...nothing, the code as the ref in the iframe...nothing!.

Not really sure how to put this together to make it work.

24 Apr 2010, 8:01 AM
#5
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Facebook "Like" button on every product page?

On a product_info page that code will produce this in the html:

http://domain.com/index.php?main_page=product_info&cPath= 65 &products_id=181 

Or whatever the details are. It will produce that wherever you put it as long as it is not already in <?php ?> tags in which case you'd need to remove the ones in my code.

So you could just put that code somewhere at the top of the page and you will see what it is outputing.

What you actually want to do is this:

<iframe src="http://www.facebook.com/widgets/like.php?href=<?php echo zen_href_link(zen_get_info_page((int)$_GET['products_id']),'cPath= '.(int)$_GET['cPath'].' &products_id=' . (int)$_GET['products_id']); ?>"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"></iframe>

But looking at it again I am not sure that the whole plan is going to work in that I am not sure the system will deal with the dynamic URL anyway. What that means is that I am not sure how the system will deal with the bit after the question mark. It might or it might not.

Nick
iszent.com

24 Apr 2010, 5:43 PM
#6
trisha1581 avatar

trisha1581

New Zenner

Join Date:
Jan 2007
Posts:
66
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

Nick,

Thank you so much that worked !!!!

24 Apr 2010, 7:04 PM
#7
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Facebook "Like" button on every product page?

Splendid. Glad it played ball. Well done!

Nick
iszent.com

25 Apr 2010, 6:33 PM
#8
scrap avatar

scrap

Zen Follower

Join Date:
Mar 2009
Posts:
103
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

niccol:

On a product_info page that code will produce this in the html:

http://domain.com/index.php?main_page=product_info&cPath= 65 &products_id=181

> 
> Or whatever the details are.  It will produce that wherever you put it as long as it is not already in <?php ?> tags in which case you'd need to remove the ones in my code.
> 
> So you could just put that code somewhere at the top of the page and you will see what it is outputing.
> 
> What you actually want to do is this:
> 
> ```
<iframe src="http://www.facebook.com/widgets/like.php?href=<?php echo zen_href_link(zen_get_info_page((int)$_GET['products_id']),'cPath= '.(int)$_GET['cPath'].' &products_id=' . (int)$_GET['products_id']); ?>"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"></iframe>

But looking at it again I am not sure that the whole plan is going to work in that I am not sure the system will deal with the dynamic URL anyway. What that means is that I am not sure how the system will deal with the bit after the question mark. It might or it might not.

Excellent, it works! Now I only have to position it...

For reference (if someone else want to do it), the file you're looking for is includes --> templates --> YOUR TEMPLATE --> template --> tpl_product_info_display.php.

29 Apr 2010, 2:27 PM
#9
kevinmc3 avatar

kevinmc3

Totally Zenned

Join Date:
Jun 2006
Posts:
786
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

Ver 1.3.8a

Sorry if a dumb question but does this code need to be added to every product page? Or is there a PHP file that will insert into every product page?

29 Apr 2010, 3:38 PM
#10
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Facebook "Like" button on every product page?

If you edit the file tpl_product_info_display.php then those edits will appear in each product info page (except if you are using different product types)

Nick
iszent.com

29 Apr 2010, 6:05 PM
#11
kevinmc3 avatar

kevinmc3

Totally Zenned

Join Date:
Jun 2006
Posts:
786
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

Could someone post a ink to an example on your site so we can see what it looks like?

30 Apr 2010, 1:39 AM
#12
solidrock avatar

solidrock

New Zenner

Join Date:
Nov 2009
Location:
Aurora, IN
Posts:
37
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

It puts the Like button there fine, and says that I "Like" it when I click it, but then it gives me an error message, and when I click on it, it says, "The page at http://mysite.com/index.php?main_page=product_info could not be reached."

Any ideas how to fix that?

niccol:

On a product_info page that code will produce this in the html:

http://domain.com/index.php?main_page=product_info&cPath= 65 &products_id=181

> 
> Or whatever the details are.  It will produce that wherever you put it as long as it is not already in <?php ?> tags in which case you'd need to remove the ones in my code.
> 
> So you could just put that code somewhere at the top of the page and you will see what it is outputing.
> 
> What you actually want to do is this:
> 
> ```
<iframe src="http://www.facebook.com/widgets/like.php?href=<?php echo zen_href_link(zen_get_info_page((int)$_GET['products_id']),'cPath= '.(int)$_GET['cPath'].' &products_id=' . (int)$_GET['products_id']); ?>"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"></iframe>

But looking at it again I am not sure that the whole plan is going to work in that I am not sure the system will deal with the dynamic URL anyway. What that means is that I am not sure how the system will deal with the bit after the question mark. It might or it might not.

1 May 2010, 10:38 PM
#13
kevinmc3 avatar

kevinmc3

Totally Zenned

Join Date:
Jun 2006
Posts:
786
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

SO, got it working. Now, has anyone figured exactly WHERE to place the code so the top of the product page doesn't look "funky"? See the big white block on below product page..

http://www.cvtreasures.com/authentic-celebrity-autographs-presidential-historical-c-67_90/ulysses-s-grant-rare-signed-check-1868-just-acquired-p-1169

1 May 2010, 10:48 PM
#14
kevinmc3 avatar

kevinmc3

Totally Zenned

Join Date:
Jun 2006
Posts:
786
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

UPDATE:
NOTE: I think the placement is OK, but it is making a big white box on every product page (see below). How can I get rid of the White Box ? i.e. a transparent background for the "Like It" button?

http://www.cvtreasures.com/vintage-movie-posters-classic-movie-posters-c-66_74/superman-mole-men-george-reeves-vintage-movie-poster-us-1-sht-p-1791

P.S. This is an AWESOME feature to add to our Zen Carts!!

2 May 2010, 1:44 PM
#16
myzcpt avatar

myzcpt

New Zenner

Join Date:
May 2010
Posts:
5
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

It puts the Like button there fine, and says that I "Like" it when I click it, but then it gives me an error message, and when I click on it, it says, "The page at http://mysite.com/index.php?main_page=product_info could not be reached."

Any ideas how to fix that?

2 May 2010, 2:48 PM
#17
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Facebook "Like" button on every product page?

@kevinmc3
Which browser are you using - looks fine in firefox.

Nick
iszent.com

2 May 2010, 3:59 PM
#19
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Facebook "Like" button on every product page?

this is what it looks like in firefox - is this different or are you expecting something else....

Nick
iszent.com

2 May 2010, 6:05 PM
#20
kevinmc3 avatar

kevinmc3

Totally Zenned

Join Date:
Jun 2006
Posts:
786
Plugin Contributions:
0

Re: Facebook "Like" button on every product page?

niccol:

this is what it looks like in firefox - is this different or are you expecting something else....

Yes, looks cleaner in FF. It doesn't have a white box around the Like It button like in IE8.

Another question. If there anyway to get the Like It posts to** include an Image of the product**? Like when we post on our Facebook "WALL" or "NOTES" , it pulls the image from the URL. Would be great if could get the Like IT code to ALSO pull the Image.