Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Send to Friend on product pages.

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 10-07-2002, 03:18 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default 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.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #2  
Old 10-28-2002, 04:08 PM
 
chirin1 chirin1 is offline
 

Newbie
  
Join Date: Oct 2002
Location: UK
Posts: 2
 

Default 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.
Reply With Quote
  #3  
Old 10-28-2002, 04:28 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default

i would definitely be interested if it works for 3.2.1

Thanks !
Reply With Quote
  #4  
Old 10-28-2002, 05:19 PM
  seaCOAST's Avatar 
seaCOAST seaCOAST is offline
 

X-Adept
  
Join Date: Oct 2002
Location: New Hampshire
Posts: 569
 

Default

BOOMER! Very slick!

Are major modifications required?

v3.2.1
__________________
Xcart V4.5.5 Gold
seaCOAST
"Live FREE or DIE!"
Reply With Quote
  #5  
Old 11-10-2002, 10:41 AM
 
japanchick japanchick is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 64
 

Default Hi Boomer

Hi Boomer,

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

Japanchick
Reply With Quote
  #6  
Old 11-10-2002, 12:26 PM
  seaCOAST's Avatar 
seaCOAST seaCOAST is offline
 

X-Adept
  
Join Date: Oct 2002
Location: New Hampshire
Posts: 569
 

Default

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?
__________________
Xcart V4.5.5 Gold
seaCOAST
"Live FREE or DIE!"
Reply With Quote
  #7  
Old 11-10-2002, 01:40 PM
 
ATKOgirl ATKOgirl is offline
 

X-Adept
  
Join Date: Sep 2002
Posts: 448
 

Default

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
__________________
X-Cart Versions: 4.1.10 and 4.2.0
Reply With Quote
  #8  
Old 11-10-2002, 01:43 PM
  seaCOAST's Avatar 
seaCOAST seaCOAST is offline
 

X-Adept
  
Join Date: Oct 2002
Location: New Hampshire
Posts: 569
 

Default

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".

__________________
Xcart V4.5.5 Gold
seaCOAST
"Live FREE or DIE!"
Reply With Quote
  #9  
Old 11-15-2002, 08:14 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

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

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.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #10  
Old 11-15-2002, 08:17 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

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

NOTE: Ooops I forgot to add a / in between mail and sendtofriend.tpl and sendtofriend_subj.tpl sorry about that.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:16 PM.

   

 
X-Cart forums © 2001-2020