X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Send to Friend on product pages. (https://forum.x-cart.com/showthread.php?t=216)

B00MER 10-07-2002 03:18 AM

Send to Friend on product pages.
 
If anyone is interested I currently have a simple method to allow users to send products to their friends email address's with a direct link back to the product. If anyone wants such a feature get in touch with me and will work on details, as I'll provide a walk through, with code snippets. This was done with version 3.2.0, but can be done to older versions as well.

chirin1 10-28-2002 04:08 PM

Send to friend
 
Hi,
I'd really appreciate it if you'd show me how to add this 'send to a friend' link to my site (www.nothingbutgifts.com).
Thanks a lot for your time, I really appreciate it,
Kind Regards,
Chirin.

Jon 10-28-2002 04:28 PM

i would definitely be interested if it works for 3.2.1

Thanks !

seaCOAST 10-28-2002 05:19 PM

BOOMER! Very slick!

Are major modifications required?

v3.2.1

japanchick 11-10-2002 10:41 AM

Hi Boomer
 
Hi Boomer,

I also am interested in learning how to do that. Please email or pm me thanks!

Japanchick

seaCOAST 11-10-2002 12:26 PM

I have a very nice javascript tell-a-friend script that works great in html pages.

I'm not sure how to make it work with the product.tpl though.

You have to put the <script></script> tag at the beginning which points the the .js file of the tell-a-friend script. The only problem is that in the product.tpl there is already a <script> line.

Is it possible to define both <script>'s?

Anyone know?

ATKOgirl 11-10-2002 01:40 PM

Hi SeaCoast,

You should be able to include two scripts in the head. I would probably keep them completely separate including enclosing each in it's own {literal} tags.

ATKOgirl

seaCOAST 11-10-2002 01:43 PM

Quote:

Originally Posted by ATKOgirl
Hi SeaCoast,

You should be able to include two scripts in the head. I would probably keep them completely separate including enclosing each in it's own {literal} tags.

ATKOgirl


I actually tried that and got an "error on page".

:?

B00MER 11-15-2002 08:14 AM

Okie so I'm feeling nice today, hopefully the favor can be returned in some way. :roll:

First create a new file called sendtofriend.php under xcart/customer/
Code:

<?php
#
# sendtofriend mod by www.molotovbliss.com
#

require "../smarty.php";
require "../config.php";
@include "./https.php";
require "./auth.php";
require "../include/categories.php";

if($active_modules["Bestsellers"])
        include "../modules/Bestsellers/bestsellers.php";

$product_info = func_select_product($productid, $user_account['membership']);
$cat = $product_info["categoryid"];

$userinfo = func_userinfo($login,$login_type);

if ($REQUEST_METHOD=="POST") {

#    phpinfo(); exit();

#
# Send mail to support
#
        $HTTP_POST_VARS["body"] = stripslashes($HTTP_POST_VARS["body"]);

        while (list($key,$val) = each($HTTP_POST_VARS))
                $contact[$key]=$val;

    $fillerror = (empty($contact["firstname"]) || empty($contact["lastname"]) || empty($contact["email"]) || empty($contact["sendtoemail"]));

        if(!$fillerror) {
                $mail_smarty->assign("contact",$contact);

                #print $contact["sendtoemail"]; exit();

                func_send_mail($contact["sendtoemail"], "mail/sendtofriend_subj.tpl", "mail/sendtofriend.tpl", $contact["email"], true);

    $productid = $product_info['productid'];
                header("Location: sendtofriend.php?section=sendtofriend&productid=$productid");
                exit;

        } else {

                $userinfo = $HTTP_POST_VARS;
                $userinfo["login"] = $userinfo["uname"];

        }
}


$smarty->assign("userinfo",$userinfo);
$smarty->assign("fillerror",$fillerror);
$smarty->assign("main","sendtofriend");
$smarty->assign("help_section",$section);
$smarty->assign("location",$location);
$smarty->assign("product",$product_info);

$smarty->display("customer/home.tpl");

?>


Next we need to let smarty know what template to use:
[skin1]/common_templates.tpl add the following after the
first if statement:

Code:

{elseif $main eq "sendtofriend"}
{include file="customer/sendtofriend.tpl"}


Now create a new file under [skin1]/customer/sendtofriend.tpl and paste the following:

Code:



{literal}
<script>
function checkEmailAddress(field) {
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

if (goodEmail) {
    return true;
} else {
        alert("E-mail address is invalid! Please correct");
        field.focus();
        field.select();
        return false;
    }
}
</script>
{/literal}
{if $smarty.get.mode eq "update"}

The product you have selected currently to send to your friend(s):



<table><tr>
<td><a href=product.php?productid={$smarty.get.productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$smarty.get.productid image_x=70 product=$products[product].product}</a></td>
<td>Product: <font class="red">{$product.product|escape}</font>

{$product.descr|truncate:255:"...":true}</td>
</tr></table>

{*$lng.txt_contact_us_header*}
{/if}



{capture name=dialog}

{if $smarty.get.mode eq "update"}
<table width=100% border=0 cellspacing=0 cellpadding=2>
<form action="sendtofriend.php?mode=update&section=sendtofriend&productid={$smarty.get.productid}" action=sendtofriend method=post name=sendtofriendform>

<tr valign=middle>
<td colspan=3 class="red">Friend Information:</td>
</tr>

<tr valign=middle>
<td class="TableCenterCustomerForm">{$lng.lbl_email}</td>
<td><font class=StarStyle>*</font></td>
<td nowrap>
<input type=text name=sendtoemail size=32 maxlength=255>
{if $fillerror ne "" and $userinfo.sendtoemail eq ""}<font class=StarStyle>&lt;&lt;</font>{/if}
</td>
</tr>

<!-- <tr><td colspan=3><small>Use , to seperate mutliple friends emails.
example: bob@bob.com, smith@smith.com, etc.</td></tr> -->
<tr><td></td></tr>

<tr valign=middle>
<td colspan=3 class="red">Your Information:</td>
</tr>

<tr valign=middle>
<td class="TableCenterCustomerForm">{$lng.lbl_first_name}</td>
<td><font class=StarStyle>*</font></td>
<td nowrap>
<input type=text name=firstname size=32 maxlength=32 value="{$userinfo.firstname}">
{if $fillerror ne "" and $userinfo.firstname eq ""}<font class=StarStyle>&lt;&lt;</font>{/if}
</td>
</tr>

<tr valign=middle>
<td class="TableCenterCustomerForm">{$lng.lbl_last_name}</td>
<td><font class=StarStyle>*</font></td>
<td nowrap>
<input type=text name=lastname size=32 maxlength=32 value="{$userinfo.lastname}">
{if $fillerror ne "" and $userinfo.lastname eq ""}<font class=StarStyle>&lt;&lt;</font>{/if}
</td>
</tr>


<tr valign=middle>
<td class="TableCenterCustomerForm">{$lng.lbl_email}</td>
<td><font class=StarStyle>*</font></td>
<td nowrap>
<input type=text name=email size=32 maxlength=128 value="{$userinfo.email}">
{if $fillerror ne "" and $userinfo.email eq ""}<font class=StarStyle>&lt;&lt;</font>{/if}
</td>
</tr>

<tr valign=top>
<td class="TableCenterCustomerForm">{$lng.lbl_message}</td>
<td></td>
<td nowrap>
<textarea cols=48 rows=12 name=body>{$userinfo.body}</textarea>

</td>
</tr>

<tr valign=middle>
<td></td>
<td></td>
<td nowrap>


{include file="buttons/submit.tpl"}
</td>
</tr>
<input type=hidden name=usertype value="{$usertype}">
<input type=hidden name=productid value="{$smarty.get.productid}">
</form>
</table>

<hr size=1>
Here is the template for the email being sent to your friend:

<UL>
Bob Smith has recommended a product to you.



Look at this cool product I found, I think its what you were looking for!



Checkout the product link below for more details:

http://www.blazingdragon.com/store/customer/product.php?productid=3



--

orders@blazingdragon.com

support@blazingdragon.com

http://www.blazingdragon.com
[/list]


Go Back {include file="buttons/go.tpl"}



{else}
Your message was succesfully sent, your friend has been informed of {$product.product|escape}.



Go Back {include file="buttons/go.tpl"}


{/if}
{/capture}
{include file="dialog.tpl" title="Send to Friend(s)" content=$smarty.capture.dialog extra="width=100%"}


Edit the contents of the template to your liking. And please make a donation as this wasn't a quick easy task, I just see so many are requesting such that would be easier to deal in a mass way, I'm just asking for some help for my time. If you can't get all this working, please email me.

B00MER 11-15-2002 08:17 AM

Forgot to mention you also need to create two other files under [skin1]/mail

First file: [skin1]/mail/sendtofriend.tpl

Code:

{$contact.firstname} {$contact.lastname} has recommended a product to you.
{if $contact.body ne ""}

{$contact.body}

{/if}
Checkout the product link below for more details:
http://www.blazingdragon.com/store/customer/product.php?productid={$contact.productid}

{include file="mail/signature.tpl"}


Next: [skin1]/mail/sendtofriend_subj.tpl

Code:

{config_load file="$skin_config"}{$contact.firstname} {$contact.lastname} has recommended a product to you at {$config.Company.company_name}{*$lng.eml_contact_us_subj*}

Sorry about that :wink:

:!: NOTE: Ooops I forgot to add a / in between mail and sendtofriend.tpl and sendtofriend_subj.tpl sorry about that.

B00MER 11-15-2002 08:25 AM

Also here is how I am linking it in the [skin1]/customer/main/product.tpl

Note that I created my own send2friend.tpl button. You can replace this with a text link if you want. :wink:

Normen 12-15-2002 02:04 PM

B00MER, i get the following error while using your script:

Code:

Warning: Smarty error: unable to read template resource: "mail/sendtofriend.tpl" in /opt/content/luckylenn.nl/HTML/store/Smarty-2.1.1/Smarty.class.php on line 546

I literally copy/paste your scripts and followed the instructions .. do you have an idea what goed wrong?

problem URL is: http://www.luckylenn.nl/store/

B00MER 12-15-2002 02:20 PM

Norman please see the note I added on the mail templates, I forgot to provide the / inbetween the mail and the template name(s).

cyberactive 12-16-2002 02:25 AM

Nic one Boomer.

But errr....

I get an access denied error....

FishBookStore 12-28-2002 08:11 PM

Great job
 
Works for me. :D

I did add <? in the first line of sendtofriend.php

http://www.fishbookstore.com/xcart/customer/product.php?productid=16133&cat=251&page=1

B00MER 12-28-2002 09:09 PM

I fixed the <? posting on the .php file, sorry about that. :wink:

indymart 01-03-2003 08:10 AM

Hi,
When i test send to friend i got :
Access denied !
You are not allowed to access that resource!
How can i fix it?
Thank you.

yamz 02-05-2003 10:16 PM

????
 
boomer, same as Norman? What do you mean about the /? in front of what?

:?

Please Help!

B00MER 02-06-2003 07:53 AM

The main reason you are possibily getting the error is you need to make sure all the filenames and locations are correct, If my post is somewhat misleading please let me know and I will reimplement it with the latest version of x-cart to see if it is still working correctly.

hth. :wink:

yamz 02-06-2003 08:59 AM

You were right!
 
Thanks Boomer, hopefully not coming off like a nag! You were right, had the sendtofriend.tpl in the wrong dir.

8O oops!

Thanks Again!

machnhed1 03-03-2003 12:45 PM

Great Script
 
Hi Boomer,

Kudos on the script, you really outdid yourself. I would like to add a slight mod for /customer/home.tpl file, let me know your thoughts on it...

-Original Code-
Code:

<title>{$lng.txt_site_title}
{if $main eq "catalog"}
        {if $location eq ""}  {$lng.txt_subtitle_home}
        {else}
        {strip}
        {section name=position loop=$location start=0 }
        {if %position.last% eq "true"} - {$location[position].0|escape}{/if}
        {/section}
        {/strip}
        {/if}
{elseif $main eq "product"}
        {if $product.product ne ''} - {$product.product}{/if}
{elseif $main eq "help"}
{$lng.txt_subtitle_help}
{elseif $main eq "cart"}
{$lng.txt_subtitle_cart}
{elseif $main eq "checkout"}
{$lng.txt_subtitle_checkout}
{elseif $main eq "order_message"}
{$lng.txt_subtitle_thankyou}
{/if}
</title>

-Modified Code-
Code:

<title>{$lng.txt_site_title}
{if $main eq "catalog"}
        {if $location eq ""}  {$lng.txt_subtitle_home}
        {else}
        {strip}
        {section name=position loop=$location start=0 }
        {if %position.last% eq "true"} - {$location[position].0|escape}{/if}
        {/section}
        {/strip}
        {/if}
{elseif $main eq "product"}
        {if $product.product ne ''} - {$product.product}{/if}
{elseif $main eq "help"}
{$lng.txt_subtitle_help}
{elseif $main eq "cart"}
{$lng.txt_subtitle_cart}
{elseif $main eq "checkout"}
{$lng.txt_subtitle_checkout}
{elseif $main eq "order_message"}
{$lng.txt_subtitle_thankyou}
{elseif $main eq "sendtofriend"}
{if $product.product ne ''} - Send {$product.product} to a Friend{/if}
{/if}
</title>

The extra elseif statement changes the title of the page and adds in the product name. A slight mod, but it may help out with the search engines a bit and is an improvement over the default title.

Hope someone gets some use of it.

:D

okdpminc 04-30-2003 07:08 PM

I've just discovered that the HTML Catalog makes a shambles of the link for sendtofriend. Is there a tweak that will fix this, as manually editing every product html page ain't gonna cut it? :)

B00MER 04-30-2003 07:19 PM

Just make the link point directly to the sendtofriend.php file.

Kinda like so:

This is on the blazingdragon.com site and it works from the html catalog. ;)

okdpminc 04-30-2003 07:32 PM

Dang Boomer! You beat me to the punch. 8O I just made the change and was going to update my post....lol. That was your basic no-brainer after I took a closer look at it. :oops: Thanks for the faster than expected post.

tpfair 07-08-2003 01:50 PM

Compatible 3.4.3 ????
 
Hello


Is there anyone who as install this mod with version 3.4.3 ????



Stefan

Xcart-Man 07-27-2003 03:34 PM

3.4.3 here working 100%
 
yeah I got it workin on 3.4.3 with no issues.

Mad 08-14-2003 10:25 AM

Got it working here as well on the newest build.

Got everything optimized to my liking. One question though, how could I get the name of the product into the actual e-mail? I don't need the description, just the name.

Great post, got it to work without issues the first time around.

Mad 08-21-2003 07:36 PM

Here is another small addition to this great mod.
Original [/customer/main/sendtofriend.tpl]:
Code:

...
</script>
{/literal}



{capture name=dialog}

{if $smarty.get.mode eq "update"}
...

Replace with [/customer/main/sendtofriend.tpl]:
Code:

...
</script>
{/literal}
{include file="location.tpl"}
{capture name=dialog}

{if $smarty.get.mode eq "update"}
...

Then, Original [/location.tpl] (yours may look different):
Code:

...
<font class=NavigationPath>{$last_location}</font>
{if $last_url ne ""}
</a>
{/if}
{/if}
/
{section name=position loop=$location}
{if $location[position].1 ne "" }<a href="{$location[position].1}">{/if}
...

Replace with [/location.tpl]:
Code:

...
<font class=NavigationPath>{$last_location}</font>
{if $last_url ne ""}
</a>
{/if}
{/if}
/
<font class=NavigationPath>{if $main eq "sendtofriend"}E-mail a Friend{/if}</font>
{section name=position loop=$location}
{if $location[position].1 ne "" }<a href="{$location[position].1}">{/if}
...


Hope this helps a few people. Thanks again for the great mod!

nerd luv 08-22-2003 04:36 PM

What a great addition! *Almost* everything is working perfectly for me...

The e-mails, although only received one time, have the TO address in there twice. ie- TO: me@me.com; me@me.com

Any ideas?

edit- got the first of my two issues fixed

mmaner 09-11-2003 07:54 AM

Acess Denied
 
Great Script Boomer. I see it live on other sites, but for somereason I'm getting an Access Denied error. Here's the URL: www.wittrans.net/wittcart/customer/home.php
And I checked the file locations. Any ideas?

yipcha 10-06-2003 11:22 PM

hey just got this script working works like a charm. Just make sure you put sendtofriend.php in xcart/customer not in skin1 which I assumed at first for some reason... Just thought I might share that with the rest of you in case anyone is pulling their hair out. I'm currently working on ver. 3.4.8 tested the script and works great Thanks Boomer! ---I'll be sending some paypal gratitude per your post as soon as I get me some green.

moshguy 10-30-2003 07:12 AM

Great idea
 
I love the idea for this mod. I'm probably going to implement it on my site. I think instead of paypal gratitude, I'm going to pick up your epanol language pack. Save me some time and head ache.

-Jeremy

B00MER 10-30-2003 08:12 AM

If you'd like to make a donation you can find a link at:
:arrow: http://www.cart-lab.com/lab/customer/help.php?section=about

If anyone has any suggestions for this mod feel free to lay them on me, I may redo this mod in the near future to be put up on cartlab with possibly more options, like admin controlable settings, multiple receiptients, and maybe building a list of items to send along with attaching a send to friend on EVERY page instead of Just products. Anyhow just some ideas. :idea:

Anyhow, enjoy! :-k

funkydunk 10-31-2003 12:16 AM

Boomer,

This is still a great mod and so suprising that xcart has not included it in releases since you originally wrote it. 8O

rrf 10-31-2003 02:17 AM

Quote:

Originally Posted by funkydunk
Boomer,

This is still a great mod and so suprising that xcart has not included it in releases since you originally wrote it. 8O


Though X-Cart license agreement does allow us to include 3rd party mods into X-Cart code, we do not do this without getting explict permission of the mod writer. So, if B00MER wants us to include this in the mainstream code, we can do this.

ETInteractive.com 10-31-2003 08:21 AM

Sure . for a FEE. :twisted:

GO get em Boomer! :lol:

funkydunk 10-31-2003 08:59 AM

RRF

If you want to pm me I may be open to offers :)

leon 11-20-2003 10:40 PM

needed indeed
 
Both the Send-to-a-friend and random-image mods should be added in the basic package IMHO (In My Humble Opinion), since these are great for cart functionality.

Hope they are included soon. :D

MER 11-24-2003 12:02 AM

Hi Boomer, I tried your MOD on 3.5.0 and got this error message after click on the 'Send to a friend' button. Do you have any idea what when wrong?

Can't to find template engine!

Tks,

Ming

B00MER 11-24-2003 09:39 PM

If your running 3.5.0:

Edit smarty.php and update the corresponding code at line 39:

Code:

#
# Define SMARTY_DIR to avoid problems with PHP 4.2.3 & SunOS
#
define('SMARTY_DIR', $xcart_dir.DIRECTORY_SEPARATOR."Smarty-2.5.0".DIRECTORY_SEPARATOR);

if (!@include(SMARTY_DIR."Smarty.class.php")) {
        if (!@include("../".SMARTY_DIR."Smarty.class.php")) {
        echo "Can't to find template engine!";
        exit;
        }
}


Should do the trick.


All times are GMT -8. The time now is 12:51 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.