Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

I want Country Name in "Email To Store Owner"


mtims48021

Recommended Posts

I have tried a dozen different times to have the Country Name display in the "Email to Store Owner" when a new customer signs up.

but all that shows is the Country ID, ie 223 for United States.

I'm sure it is just an Mysql Query to table_countries, but I haven't figured out the code yet. If someone has done this let me know.

The closest I have come is:

$db = mysql_connect("localhost", "root", "password");

mysql_select_db("table_countries",$db);

$result = mysql_query("SELECT country_name FROM table_countries where country_id = customers_country_entry_id",$db);

I haven't tried this code yet, I just thought of it as I was writing this!

ANY THOUGHTS?

Link to comment
Share on other sites

I think this code would return the country name, but I haven't tried it:

 

$country = tep_get_country_name($customer_country_id);

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Can you point me to the file that has the code that sends the email to the store owner when someone signs up?

:unsure:

 

I just tested it and it works for me when I inserted the code in a "test" page I have.

 

Maybe you don't have it in the correct place in the code.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Can you point me to the file that has the code that sends the email to the store owner when someone signs up?

:unsure:

 

I just tested it and it works for me when I inserted the code in a "test" page I have.

 

Maybe you don't have it in the correct place in the code.

 

 

This is line 247 to line 265 of create_account.php:

 

tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

$country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . tep_db_input($country) . "'");

 

 

$email_text_owner_data =

"Client ID: ".$customer_id."\r\n".

"Name: ".$firstname." ".$lastname."\r\n".

"E-mail: ".$email_address."\r\n".

"Phone: ".$telephone."\r\n".

"Fax: ".$fax."\r\n".

"Address: ".$street_address."\r\n".

"City: ".$city."\r\n".

"Suburb: ".$suburb."\r\n".

"State: ".$state."\r\n".

"Zipcode: ".$postcode."\r\n".

"Country ID: ".$country."\r\n".

"Country Name: ".$country_query."\r\n".

"";

 

The $country_query was one attempt that did not produce the wanted result

Link to comment
Share on other sites

That's the code that sends the email to the person who just registered, not the store owner.

 

I already know about that code,

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

That's the code that sends the email to the person who just registered, not the store owner.

 

I already know about that code,

 

That is the code for the email that goes to the store owner when a new customer signs up!!

Link to comment
Share on other sites

tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

  function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {

Note that the "to" email address is FIRST.

 

Note that the "from" email address is LAST.

 

That code sends to the customer, NOT the owner.

 

I have searched for the code that sends to the owner, and it eludes me.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

In the create account file you could change this code:

 

	  $email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
  tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

to

 

	  $email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING . "\n\nCountry: " . tep_get_country_name($customer_country_id);
  tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

Maybe that will get you what you want?

:unsure:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

$country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . tep_db_input($country) . "'");

 

tep_db_query() just returns the result of mysql_query(), which is not the value you want (it's a DB resource). One way to do it is to add:

 

$country_query_row = mysql_fetch_row($country_query);

$country_name = $country_query_row['countries_name'];

 

...

 

"Country Name: ".$country_name."\r\n".

 

I'm sure there are other ways...

Link to comment
Share on other sites

tep_db_query() just returns the result of mysql_query(), which is not the value you want (it's a DB resource). One way to do it is to add:

 

$country_query_row = mysql_fetch_row($country_query);

$country_name = $country_query_row['countries_name'];

 

...

 

I'm sure there are other ways...

 

Thanks for trying, but I'm still not getting country name.

 

I changed create_account to the following as you suggested:

 

tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

$country_query_row = mysql_fetch_row($country_query);

 

$country_name = $country_query_row['countries_name'];

 

$email_text_owner_data =

"Client ID: ".$customer_id."\r\n".

"Name: ".$firstname." ".$lastname."\r\n".

"E-mail: ".$email_address."\r\n".

"Phone: ".$telephone."\r\n".

"Fax: ".$fax."\r\n".

"Address: ".$street_address."\r\n".

"City: ".$city."\r\n".

"Suburb: ".$suburb."\r\n".

"State: ".$state."\r\n".

"Zipcode: ".$postcode."\r\n".

"Country ID: ".$country."\r\n".

"Country Name: ".$country_name."\r\n".

"";

When I added a customer, the Country ID was correct, 223 but the Country Name was blank. Is the above what you had in mind?

Link to comment
Share on other sites

Thanks for trying, but I'm still not getting country name.

 

I changed create_account to the following as you suggested:

 

tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

$country_query_row = mysql_fetch_row($country_query);

 

$country_name = $country_query_row['countries_name'];

 

$email_text_owner_data =

"Client ID: ".$customer_id."\r\n".

"Name: ".$firstname." ".$lastname."\r\n".

"E-mail: ".$email_address."\r\n".

"Phone: ".$telephone."\r\n".

"Fax: ".$fax."\r\n".

"Address: ".$street_address."\r\n".

"City: ".$city."\r\n".

"Suburb: ".$suburb."\r\n".

"State: ".$state."\r\n".

"Zipcode: ".$postcode."\r\n".

"Country ID: ".$country."\r\n".

"Country Name: ".$country_name."\r\n".

"";

When I added a customer, the Country ID was correct, 223 but the Country Name was blank. Is the above what you had in mind?

 

This is really getting to me! If I go to phpMyadmin and make the following query:

$sql = 'SELECT countries_name FROM `countries` WHERE countries_id = "223"';

It returns United States.

But if I change it to:

$countries_name = 'SELECT countries_name FROM `table_countries` WHERE countries_id = "$countries_id"';

and put the code in create_account, it doesn't return anything.

Where am I going wrong in my syntax?

Maybe I should repost the question in a different area?

Link to comment
Share on other sites

Perhaps values are not set to what you think when you're useing them, I put:

 

$to = 'my variable' ; print "<script>alert('$to');</script>";

 

To see values within code, Note that this code can create a header already sent error.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I inserted this code:

 

$country_name = tep_get_country_name($customer_country_id);
$email_text_owner_data = "Client ID: ". $customer_id ."\n".
"Name: " . $firstname . " " . $lastname . "\n".
"E-mail: " . $email_address . "\n".
"Phone: " . $telephone . "\n".
"Fax: " .  $fax . "\n".
"Address: " . $street_address . "\n".
"City: " . $city . "\n".
"Suburb: " . $suburb . "\n".
"State: " . $state . "\n".
"Zipcode: " . $postcode . "\n".
"Country ID: " . $country . "\n".
"Country Name: " . $country_name . "\n";
mail("[email protected]", "Register info", $email_text_owner_data,"From: [email protected]");

(You'll need to substitue the to and from email addresses).

 

Right after this line in create_account.php

 

	  tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

And this is what I got in the mail:

 

Client ID: 24 
Name: xxx xxxxxxxxxx
E-mail: [email protected] 
Phone: xxx-xxx-xxxx 
Fax: 
Address: xxxx xx xxxxx xxxx 
City: xxxxxxx 
Suburb: 
State: xxxxxx 
Zipcode: xxxxx 
Country ID: 223 
Country Name: United States

Of course, the real data I replaced with x's, but you get the picture.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

I inserted this code:

 

$country_name = tep_get_country_name($customer_country_id);
$email_text_owner_data = "Client ID: ". $customer_id ."\n".
"Name: " . $firstname . " " . $lastname . "\n".
"E-mail: " . $email_address . "\n".
"Phone: " . $telephone . "\n".
"Fax: " .  $fax . "\n".
"Address: " . $street_address . "\n".
"City: " . $city . "\n".
"Suburb: " . $suburb . "\n".
"State: " . $state . "\n".
"Zipcode: " . $postcode . "\n".
"Country ID: " . $country . "\n".
"Country Name: " . $country_name . "\n";
mail("[email protected]", "Register info", $email_text_owner_data,"From: [email protected]");

(You'll need to substitue the to and from email addresses).

 

Right after this line in create_account.php

 

	  tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

And this is what I got in the mail:

 

Client ID: 24 
Name: xxx xxxxxxxxxx
E-mail: [email protected] 
Phone: xxx-xxx-xxxx 
Fax: 
Address: xxxx xx xxxxx xxxx 
City: xxxxxxx 
Suburb: 
State: xxxxxx 
Zipcode: xxxxx 
Country ID: 223 
Country Name: United States

Of course, the real data I replaced with x's, but you get the picture.

 

Wow, now i'm really confused. I replaced my code with yours and re-registered. The email that I (as owner) got had everything correct BUT THE COUNTRY NAME. It was blank again.

This should have returned the country name but didn't whats going on?

$country_name = tep_get_country_name($customer_country_id);

Link to comment
Share on other sites

Beats me!

:huh:

 

The only thing I can think of would be a screwed up country table in the DB.

 

Try registering usiing other country names and see what happens.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Wow, now i'm really confused. I replaced my code with yours and re-registered. The email that I (as owner) got had everything correct BUT THE COUNTRY NAME. It was blank again.

This should have returned the country name but didn't whats going on?

$country_name = tep_get_country_name($customer_country_id);

 

 

Hey Guys, I finally solved it!!!!!!! But don't know why

 

You had the code: $country_name = tep_get_country_name($customer_country_id); and said it produced the country name. It didn't for me. So I tried.

$country_name = tep_get_country_name($country_id); Still no cigar. So I changed it to:

$country_name = tep_get_country_name($country); That did the trick because $country returns country code.

This is the code I ended up with:

 

$country_name = tep_get_country_name($country);

$email_text_owner_data =

"Client ID: ".$customer_id."\r\n".

"Name: ".$firstname." ".$lastname."\r\n".

"E-mail: ".$email_address."\r\n".

"Phone: ".$telephone."\r\n".

"Fax: ".$fax."\r\n".

"Address: ".$street_address."\r\n".

"City: ".$city."\r\n".

"Suburb: ".$suburb."\r\n".

"State: ".$state."\r\n".

"Zipcode: ".$postcode."\r\n".

"Country ID: ".$country."\r\n".

"Country Name: ".$country_name."\r\n".

"";

 

So simple and I must have tried at least 30-40 different combinations.

Anyways, Thanks Everyone.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...