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.


All times are GMT -8. The time now is 01:11 PM.

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