![]() |
Adding a "How Did You Hear About Us" ??
I would like to add a text input field on the registration page that displays with the user information. I would like it to be a "How Did You Hear About Us" textarea input multiline. Will someone please give me an example of code to edit and if I need to add a field to my database? I use phpAdmin and I'm pretty good with the database part, just a complete newbie who is eager to learn when it comes to the smarty template. I have a feeling I will add the text input to the register.tpl, then edit some file that writes to the database, probably a php file and then edit a php file that does the query from the database with a display. I have the concept, but I can't afford to mess up the variables. Any help would be greatly appreciated. Thank you.
Chris |
I DID IT!!!
This post is kinda wide?
Wow, my first successful edit..I searched for a post and found this: Quote:
Code:
{* $Id: register.tpl,v 1.50 2002/11/18 13:17:24 alfiya Exp $ *} And here is my includes/register.php code: Code:
<? I have one problem, I can't get the input box to display as multiline. I tried changing the input to "textarea" and putting rows=5, but no luck. I guess it doesn't matter. If anyone sees any problems, please let me know. Thanks, Chris |
This line was added in 3.3.5 in the original register.php file (v 1.60.2.4) for anti-hacking. If you use the mod from this post, also put in this snippet at line 53:
Code:
if ($current_area != "A" && $current_area!=$usertype && $mode!="checkout") { ...also, because it looks like your version of the register.tpl file has the language variables stripped out, I just added this to my version (just above where they commented out the Social Security fields around line 87): Code:
{* Added How Heard Here *} |
Ok - I found a problem with the register.php mods - the "hear" field is not updated when the user or admin modifies the profile. I fixed this.
So - This is the entire final include/register.php for this mod: Code:
<? ...and here is the complete main/register.tpl file with the appropriate mods: Code:
{* $Id: register.tpl,v 1.50 2002/11/18 13:17:24 alfiya Exp $ *} The only other things to remember to do is: - Add the field hear to the xcart_customers table - Add the lbl_how_heard variable to the languages |
You the man.
Thanks for the help, I sure hope we helped some others. What is your site you are working on, mines is http://www.pfgpromotionals.com.
Have a nice day. Chris |
Quote:
I'll post my project info in the Member Websites area with details when it is completed. Your site looks awesome! Excellent job! Is this your business or a client? |
Thanks.
Thanks, the site is for a client. I can't take too much credit, I am a designer and my home site right now, just to be a place holder is http://www.iexweb.com. The pfgpromotionals.com was a template that I modified a great deal and had x-cart implement the design. I do not usually use templates, but this one just struck my eye and I figure I have a business, so its the best work I can provide at the lowest cost and still make my margins. Your point b site is really professional. My new site I am working on will be more professional and what I have had in mind the whole time, its just now coming out of me. Thanks for your help.
Chris |
Okay, this is very cool and is exactly what I am looking for. Thanks for supplying this! I do have one problem...
Quote:
I had no problem adding the lbl_how_heard variable to the languages, but I am still super new to other parts. So new in fact, that I have no idea how to add the "hear" field to the "xcart_customers" table. Would someone mind helping me out with how to do this? It would be very much appreciated! :D Jason |
You can use the phpMyAdmin interface to add a field or use the Patch/Upgrade area of your xcart admin - at the bottom of the screen, paste this code into the Query box and click Apply:
Code:
ALTER TABLE `xcart_customers` ADD `hear` VARCHAR(255) NOT NULL; That should do it! |
Quote:
I used the Patch/Upgrade area of xcart admin (I know nothing about phpmyadmin) and when I went to test my store, I get a connection refused error on step 2 of the checkout process after selecting credit card and clicking continue. This was copying the code exactly from your post. I restored my database and tried to enter the code again, but this time changing the Code:
` ALTER TABLE `xcart_customers` ADD `hear` VARCHAR(255) NOT NULL; TO ALTER TABLE 'xcart_customers' ADD 'hear' VARCHAR(255) NOT NULL; I did thins thinking thios message board software converted some of the characters when displaying a post. In doing that, I get an error: Quote:
Remember how I said I am new at this? :) Any idea what I am doing wrong? Jason |
It worked fine for me as originally posted. The "connection refused" error would have nothing to do with adding the field anyway and when you modified the SQL and ran it the second time and got the "SQL PATCH FAILED..." message - this is probably because the field is already there.
The problem with the "Connection Refused" issue at checkout could be related to using HTTPS if you have that setup in the credit card processing. |
Quote:
I am sorry for wasting your time with my last post. It turned out there was a firewall issue that was not letting me get to our secure server. It worked just fine when testing outside of our network. :oops: :oops: Now for another twist... Is there an easy way to make that "hear" variable to be passed into the order? Our order department needs that information. Jason |
Yes
I am not sure if you need the exact code, but you will need to add a field to the table, " xcart_orders" that represents the variable that you are using for your "how did you hear about us" input field. Then you will have to change a php file that writes to the database, its mentioned earlier in this post I think. Maybe some of our friends here can help. Not sure if this helps, but it will get you started, which if you are like me and do not know what to do most of the time, is useless.
|
Hoo boy...I hate being a newbie. :oops:
|
Adding the new field to the admin email
I got the mod to work. Thanks. I'd like to add the field to the email that is sent to the administrator. I added this line to the order_notification_admin:
Code:
{$lng.lbl_how_heard}: {$order.hear} Of course the $lng.lbl_how_heard shows up, but the value isn't there (it was just a shot in the dark). Does anyone know how I can refer to this variable? Am I missing a step somewhere? |
try {$userinfo.hear}
|
no luck. thanks anyway.
|
In case anyone else is interested...
This is how I added the extra field to the admin email. There's probably a better way to do it, but this works.
[skin]/mail/order_notification_admin.tpl - add the following line wherever you want the extra field to show up in the email: Code:
{$lng.lbl_how_heard}: {$hearabout} Code:
$ha_result = func_query_first ("SELECT hear FROM xcart_customers WHERE login='$userinfo[login]'"); Code:
$prefix = ($order_status=="I"?"init_":""); I never imagined that adding a field to the checkout form could be so complicated! I really shouldn't be. |
I try
I try both examples with no sucess
Quote:
and Quote:
can someone help me. the field shows up in the register.php but it won't send the data to mysql and I don't see it on the register email my site is: http://www.wildshopping.com thanks in advance |
All examples (including e-mail) work fine for me here. Great mod, thanks!
|
Drop Down
Has anyone added a drop down box to this?
Thanks! |
Useful little mod but copying the files doesnt work in 4.0.13 so if its useful to anyone these are the mods for 4.0.13.
Quote:
Add the lbl_how_heard variable to the languages in include/register.php Find .. Code:
db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'"); Code:
db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id', hear='$hear' WHERE login='$login' AND usertype='$login_type'"); Code:
db_query("INSERT INTO $sql_tbl[customers] (login,usertype,password,password_hint,password_hint_answer,title,firstname,lastname,company,b_address,b_city,b_county,b_state,b_country,b_zipcode,s_address,s_city,s_county,s_state,s_country,s_zipcode,phone,email,fax,url,card_name,card_type,card_number,card_expire,card_cvv2,first_login,status,referer,pending_membership,ssn,parent,pending_plan_id,change_password) VALUES ('$uname','$usertype','$crypted','".@$password_hint."','".@$password_hint_answer."','$title','$firstname','$lastname','$company','".$b_address."\n".$b_address_2."','$b_city','".(@$b_county)."','$b_state','$b_country','$b_zipcode','".$s_address."\n".$s_address_2."','$s_city','".(@$s_county)."','$s_state','$s_country','$s_zipcode','$phone','$email','$fax','$url','".@$card_name."','".@$card_type."','".addslashes(text_crypt(@$card_number))."','".@$card_expire."','".@$card_cvv2."','".time()."','Y','".@$RefererCookie."','".@$pending_membership."','".@$ssn."', '$parent', '$pending_plan_id','$change_password')"); Code:
db_query("INSERT INTO $sql_tbl[customers] (login,usertype,password,password_hint,password_hint_answer,title,firstname,lastname,company,b_address,b_city,b_county,b_state,b_country,b_zipcode,s_address,s_city,s_county,s_state,s_country,s_zipcode,phone,email,fax,url,card_name,card_type,card_number,card_expire,card_cvv2,first_login,status,referer,pending_membership,ssn,parent,pending_plan_id,change_password,hear) VALUES ('$uname','$usertype','$crypted','".@$password_hint."','".@$password_hint_answer."','$title','$firstname','$lastname','$company','".$b_address."\n".$b_address_2."','$b_city','".(@$b_county)."','$b_state','$b_country','$b_zipcode','".$s_address."\n".$s_address_2."','$s_city','".(@$s_county)."','$s_state','$s_country','$s_zipcode','$phone','$email','$fax','$url','".@$card_name."','".@$card_type."','".addslashes(text_crypt(@$card_number))."','".@$card_expire."','".@$card_cvv2."','".time()."','Y','".@$RefererCookie."','".@$pending_membership."','".@$ssn."', '$parent', '$pending_plan_id','$change_password','$hear')"); Code:
$profile_modified_data[$user] = $userinfo; Code:
$userinfo[hear]=stripslashes($hear); in include/func.php Find.. Code:
$mail_smarty->assign("userinfo",$order_data["userinfo"]); Directly below it add.. Code:
$ha_result = func_query_first ("SELECT hear FROM xcart_customers WHERE login='$userinfo[login]'"); in skin1/customer/main/ Find .. Code:
{include file="main/register_personal_info.tpl" userinfo=$userinfo} Directly below it add.. Code:
{* Added How Heard Here *} Thats the mod completed, if you want it to appear on the admin email received after a sale add the following .. in skin1/mail/order_notification_subj.tpl After line .. Code:
{config_load file="$skin_config"}{ $config.Company.company_name }: {$lng.lbl_order} #{$order.orderid} {$lng.eml_notification} Add.. Code:
{$lng.lbl_how_heard}: {$hearabout} I take no credit for this mod i just made it work on Version4.0.13, thanx to you guys that made it |
:!: Just wanted to note that this can now be done with the custom fields that are built-in in version 4.0.x of X-Cart. You can find it in General Settings->User Profile options. :wink:
|
:oops: Thanx BOOMER, Errmmm Yup that would have been a simpler solution 8O, lol
|
Please how to make those extra fields bi lingual?
|
Re: Adding a "How Did You Hear About Us" ??
Just a quick update to this.
After you add the custom fields using General Settings > User Profile Options, you may want it to appear on your order pages (admin side) so that you can see where customers have come from when you come to process the orders. Open: skin1/main/history_order.tpl Find: {if $usertype eq "A"} {$lng.lbl_status}: {include file="main/order_status.tpl" status=$order.status mode="select" name="status"} <P> Change it to: {if $usertype eq "A"} {$lng.lbl_status}: {include file="main/order_status.tpl" status=$order.status mode="select" name="status"} <br><br> {foreach from=$customer.additional_fields item=v} {if $v.section eq 'A'} {if $is_header ne 'Y'} {/if} {$v.value} {/if} {/foreach} <P> That's it! Now, when a new customer registers and places an order you will be able to see where that customer has come from when you view their order in the admin section. (It appears underneath the dropdown menu called 'Status', and above the 'Tracking Number' text box) This was tested on 4.0.16, but should be fine with other versions too. |
Re: Adding a "How Did You Hear About Us" ??
Done now, thanks.
|
Re: Adding a "How Did You Hear About Us" ??
Thanks for this info.
I have version 4.1.8. I looked in the file skin1/main/history_order.tpl but couldnt quite see the same information. Is there any chance that i could have the "how did you hear about us" script for my version. Cheers |
Re: Adding a "How Did You Hear About Us" ??
you don't need a script ...why don't u just add an extra field and have a select box with the options..?
|
Re: Adding a "How Did You Hear About Us" ??
Thanks Mitash, i think i have figured it now via your method.
Is there any way that we can pull this information received from customers, into statistics? |
Re: Adding a "How Did You Hear About Us" ??
i think u should be able to do it...
u may have to check in PHPMyadmin to see which table is storing that info and then write a SQL query to spit the results for u... ;) |
Re: Adding a "How Did You Hear About Us" ??
Is there a way for you to put the "How did you hear about us?" on the check page and have it print on the invoice?
We have catalog codes and when a customer places an order we need to know what catalog they are using for each order. |
All times are GMT -8. The time now is 10:51 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.