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

Email cart contents?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 09-14-2009, 11:00 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Re: Email cart contents?

Got a little bit further, managed to get the email sending the product code and price through to me now

Would you know how to get the customers email address and their shipping address on the email that comes throught to me? and also if I could get the email to come FROM the customer so that I can reply directly to it?

many thanks for your help, I am nearly there now.

Regards

Dan


<?php
require "./auth.php";
x_load('cart');

$emailSentTo = "info@here.com";
$subjectOfEmail = "Catac Shipping Quote";

//========= no need to edit bellow

// Set HTML Mail Header
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// The Message
$message = $GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"];

//Cleaning Message

for ($i = 0; $i < $cart["max_cartid"]; $i++){


$message = $cart["products"][$i]["productcode"];
$message3 = $cart["products"][$i]["product"];
$message2 = $cart["display_discounted_subtotal"];


}
// Sending
mail($emailSentTo, $subjectOfEmail, $message, $message2, $headers);

//Thanking
echo "<script language=\"javascript\" type=\"text/javascript\">
alert('Thank You, We will contact you shortly.');
window.location = \"http://$_SERVER[HTTP_HOST]\";
</script>
";
?>
__________________
X Cart Version 4.2
Reply With Quote
  #12  
Old 09-22-2009, 01:41 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Re: Email cart contents?

nearly done this now and works quite well

Just need 2 things:

the product options (ie size or colour chosen) to show on my email (everything else such as item ordered, code etc. does)

and 2 my Email is coming back FROM Apache in the header, need somehow to either make the users email appear in the FROM header or just to show FROM Your Site.

Anyone got any ideas?

Regards

Dan

THIS IS THE CODE THAT IS WORKING WELL.


<?php
require "./auth.php";
x_load('cart','user','order','tests');
require $xcart_dir."/include/cart_process.php";
include $xcart_dir."/shipping/shipping.php";

$smarty->assign("register_script_name",(($config["Security"]["use_https_login"] == "Y") ? $xcart_catalogs_secure["customer"]."/" : "")."cart.php");
#
# Register member if not registerred yet
# (not a newbie - do not show help messages)
#
if ($mode == "checkout" && !$func_is_cart_empty) {
$usertype = "C";
$old_action = $action;
$action = "cart";
$smarty->assign("action", $action);
$newbie = "Y";
if (empty($login))
include $xcart_dir."/include/register.php";

if (!empty($auto_login)) {
func_header_location("cart.php?mode=checkout&regis tered=");
}

$saved_userinfo = isset($userinfo) ? $userinfo : array();
$action = $old_action;
$smarty->assign("newbie", $newbie);
}

if (!empty($login))
$userinfo = func_userinfo($login, $current_area, false, false, "H");
x_session_save();




$emailSentTo = "info@uorsite.com";
$subjectOfEmail = "Catac Shipping Quote";

//========= no need to edit bellow

// Set HTML Mail Header
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// The Message
$message = $GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"];

//Cleaning Message

$message .= "Products Required";
$message .= "\n\n";
for ($i = 0; $i < $cart["max_cartid"]; $i++){
$message .= "Product Name: ";$message .= $cart["products"][$i]["product"];
$message .= "\n";
$message .= "Product Code: ";$message .= $cart["products"][$i]["productcode"];
$message .= "\n";
$message .= "Quantity: ";$message .= $cart["products"][$i]["amount"];
$message .= "\n\n";
}
$message .= "Cost of products BEFORE SHIPPING: ";$message .= $cart["subtotal"];

$message2 .= "\n";
$message2 .= "Customer Details & Address Items to be Shipped to";
$message2 .= "\n\n";
$message2 .= "Name: ";$message2 .= $userinfo["b_firstname"];
$message2 .= $userinfo["b_lastname"];
$message2 .= "\n";
$message2 .= "Email: ";$message2 .= $userinfo["email"];
$message2 .= "\n\n";
$message2 .= "City: ";$message2 .= $userinfo["b_city"];
$message2 .= "\n";
$message2 .= "Country: ";$message2 .= $userinfo["b_countryname"];
$message2 .= "\n";
$message2 .= "Post code: ";$message2 .= $userinfo["b_zipcode"];
$message2 .= "\n\n";



// Sending
mail($emailSentTo, $subjectOfEmail, $message, $message2, $headers);

//Thanking
echo "<script language=\"javascript\" type=\"text/javascript\">
alert('Thank you for enquiring about our products, we will contact you shortly with your shipping costs.');
window.close();
</script>
";
?>
__________________
X Cart Version 4.2
Reply With Quote
  #13  
Old 09-22-2009, 02:11 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default Re: Email cart contents?

you need to specify the from header for the email, see here for help,

http://uk3.php.net/manual/en/function.mail.php
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #14  
Old 09-22-2009, 02:57 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Re: Email cart contents?

Thanks for the reply, but this is not working.

I think it's because I have 5 parts in the mail code below (ie an extra $message):

mail($emailSentTo, $subjectOfEmail, $message, $message2, $headers);

I can get it working when I take out $message2 and leave 4 parts in the header.

I really need all 5, any ideas?

Regards

Dan
__________________
X Cart Version 4.2
Reply With Quote
  #15  
Old 09-22-2009, 03:18 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default Re: Email cart contents?

the mail function:

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

so you have:
$emailsentto as $to
$subjectOfEmail as $subject
$message as $message
$message2 as $additionalheaders
$headers as $additionalparameters

so your $message2 is moving all of the parameters into the wronf places which is why it doesn't work with it in, but it does without it. You need to combine your $message and $message2 into a single variable to be passed to the mail function.

Try changing to:

Code:
//Cleaning Message $message .= "Products Required"; $message .= "\n\n"; for ($i = 0; $i < $cart["max_cartid"]; $i++){ $message .= "Product Name: ";$message .= $cart["products"][$i]["product"]; $message .= "\n"; $message .= "Product Code: ";$message .= $cart["products"][$i]["productcode"]; $message .= "\n"; $message .= "Quantity: ";$message .= $cart["products"][$i]["amount"]; $message .= "\n\n"; } $message .= "Cost of products BEFORE SHIPPING: ";$message .= $cart["subtotal"]; $message .= "\n"; $message .= "Customer Details & Address Items to be Shipped to"; $message .= "\n\n"; $message .= "Name: ";$message2 .= $userinfo["b_firstname"]; $message .= $userinfo["b_lastname"]; $message .= "\n"; $message .= "Email: ";$message2 .= $userinfo["email"]; $message .= "\n\n"; $message .= "City: ";$message2 .= $userinfo["b_city"]; $message .= "\n"; $message .= "Country: ";$message2 .= $userinfo["b_countryname"]; $message .= "\n"; $message .= "Post code: ";$message2 .= $userinfo["b_zipcode"]; $message .= "\n\n";

you can only assign 1 variable to be the actual message.
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:31 PM.

   

 
X-Cart forums © 2001-2020