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
  #1  
Old 09-13-2009, 05:18 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Email cart contents?

Hi,

I need to use "Email us for shipping costs" on a site for any country outside the UK.

For anyone outside the UK I have not put any shipping costs into my xcart admin.

The user goes through to the basket and sees the message "Before we can process your order we need to work out your shipping costs." which is fine.

I need for the to somehow be able to send me an email with their cart contents so that I can work out their shipping can this be done? ie I don not want them to have to type out everything in their basket just press a button and I get a copy of the products.

Thanks in advance

Dan
__________________
X Cart Version 4.2
Reply With Quote
  #2  
Old 09-14-2009, 03:38 AM
  ElegantXMods.com's Avatar 
ElegantXMods.com ElegantXMods.com is offline
 

Advanced Member
  
Join Date: Apr 2009
Location: Stirling, UK
Posts: 94
 

Default Re: Email cart contents?

Do you have any PHP experience?

If so, you could create a PHP page on the site root, say called emailcart.php - in this, the first lines would read

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

This will give you access to the $cart variable, then just loop through $cart["products"], writing the details to a table, then use some of the other $cart variables to put in total, taxes, discounts etc. then wrap that whole string up into PHP's mail function and send it off to your address.

Then simply use JavaScript so that when someone clicks on that button, a popup box appears with emailcart.php loaded. Use JavaScript within emailcart.php to close the popup window when the page has fully loaded (i.e. the mail has been sent).

Does this make sense?
__________________
John
ElegantXMods.com

QuickOrder AJAX-based search and ordering system now available
giving you complete control over how customers browse and search for your products. Click here for details.
PriceSlider - easily filter categories by price range - only $9.99 - details here

X-Cart 4.1, X-Cart 4.2 on Windows/IIS and Linux/Apache.
Reply With Quote
  #3  
Old 09-14-2009, 04:23 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Re: Email cart contents?

Thank you very much for the reply.

Not sure I understand the following:

This will give you access to the $cart variable, then just loop through $cart["products"], writing the details to a table, then use some of the other $cart variables to put in total, taxes, discounts etc. then wrap that whole string up into PHP's mail function and send it off to your address.

The other parts make sense.

Thank you again, this is very helpful.

Regards

Dan
__________________
X Cart Version 4.2
Reply With Quote
  #4  
Old 09-14-2009, 04:28 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Re: Email cart contents?

Sorry to bother you again but how would the script be written to email the cart contents straight through to the email address info@test.com.
__________________
X Cart Version 4.2
Reply With Quote
  #5  
Old 09-14-2009, 04:50 AM
  ElegantXMods.com's Avatar 
ElegantXMods.com ElegantXMods.com is offline
 

Advanced Member
  
Join Date: Apr 2009
Location: Stirling, UK
Posts: 94
 

Default Re: Email cart contents?

Not tested this, but it should be pretty close to what you want:

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

$html = "
<body>
<h2>Date: ". date(DATE_RFC822) ."</h2>

<table>
<tr>
<th>Product Code</th>
<th>Product Name</th>
<th>Price (". $config["General"]["currency_symbol"] .")</th>
<th>Qty</th>
<th>Subtotal (". $config["General"]["currency_symbol"] .")</th>
</tr>";

for ($i = 0; $i < $cart["max_cartid"]; $i++){
$html .= "<tr>
<td>". $cart["products"][$i]["productcode"] ."</td>
<td>". $cart["products"][$i]["product"] ."</td>
<td>". $cart["products"][$i]["price"] ."</td>
<td>". $cart["products"][$i]["amount"] ."</td>
<td>". $cart["products"][$i]["display_subtotal"] ."</td>
</tr>";
}

$html .= "</table>
<table>
<tr>
<td>Subtotal (". $config["General"]["currency_symbol"] .")</td>
<td>". $cart["subtotal"] ."</td>
</tr>
<tr>
<td>Discount (". $config["General"]["currency_symbol"] .")</td>
<td>". $cart["discount"] ."</td>
</tr>
<tr>
<td>Taxes: (". $config["General"]["currency_symbol"] .")</td>
<td>". $cart["tax_cost"] ."</td>
</tr>
<tr>
<td><b>Total (". $config["General"]["currency_symbol"] .")</b></td>
<td><b>". $cart["display_discounted_subtotal"] ."</b></td>
</tr>
</table>
</body>";

mail ("from@domain.com", "to@domain.com", "Subject Line", $html);

?>
__________________
John
ElegantXMods.com

QuickOrder AJAX-based search and ordering system now available
giving you complete control over how customers browse and search for your products. Click here for details.
PriceSlider - easily filter categories by price range - only $9.99 - details here

X-Cart 4.1, X-Cart 4.2 on Windows/IIS and Linux/Apache.
Reply With Quote
  #6  
Old 09-14-2009, 05:17 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Re: Email cart contents?

Thanks very much,

Just tried it out.

created a new page called emailcart.php and put this in my xcart directory root directory along with the home.php, cart.php etc.)

Copied the code you kindly wrote below into emailcart.php and put the file over.

Then made a link on my cart.php page to open up mydomain/shop/emailcart.php in a blank window, the page opens up but it is completely blank. There is nothing at all on the page.

Any ideas?

I'm sorry to keep on bothering you but i'm not that experienced with this code.

Sorry

Thank you for your patience and help, it is very much appreciated.

Regards

Dan
__________________
X Cart Version 4.2
Reply With Quote
  #7  
Old 09-14-2009, 05:45 AM
  ElegantXMods.com's Avatar 
ElegantXMods.com ElegantXMods.com is offline
 

Advanced Member
  
Join Date: Apr 2009
Location: Stirling, UK
Posts: 94
 

Default Re: Email cart contents?

The page itself won't show anything, all it does is put together a bunch of text and mails it out.

A few tips:

If there are no error messages, then the mail may have been sent correctly, did you remember to change 'to@domain.com'?

Have you got Firebug and Firefox? Did the page request come back with 200 OK or 500 Internal Server Error?
__________________
John
ElegantXMods.com

QuickOrder AJAX-based search and ordering system now available
giving you complete control over how customers browse and search for your products. Click here for details.
PriceSlider - easily filter categories by price range - only $9.99 - details here

X-Cart 4.1, X-Cart 4.2 on Windows/IIS and Linux/Apache.
Reply With Quote
  #8  
Old 09-14-2009, 06:09 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Re: Email cart contents?

yes, I did change the email address to the one I wanted.

Just cannot get it to work for some reason.

I cannot see any button/link to close the window and also no email whatsoever comes back to me

Regards

Dan
__________________
X Cart Version 4.2
Reply With Quote
  #9  
Old 09-14-2009, 07:33 AM
  ElegantXMods.com's Avatar 
ElegantXMods.com ElegantXMods.com is offline
 

Advanced Member
  
Join Date: Apr 2009
Location: Stirling, UK
Posts: 94
 

Default Re: Email cart contents?

Hi Dan,

Unfortunately I don't have the time at present to debug this for you. Have you tried the following?
  • Echo $html to see what it's generating?
  • Determined if the page is coming back with a 500 Internal Server Error
  • Enabled full error reporting for that page to see any errors?
  • Checked the mail function - http://uk.php.net/manual/en/function.mail.php - a quick look here would tell you i messed up the syntax od the mail function. Again, because I'm pretty much doing this from memory, so you'll need to do some error checking before it works correctly.
__________________
John
ElegantXMods.com

QuickOrder AJAX-based search and ordering system now available
giving you complete control over how customers browse and search for your products. Click here for details.
PriceSlider - easily filter categories by price range - only $9.99 - details here

X-Cart 4.1, X-Cart 4.2 on Windows/IIS and Linux/Apache.
Reply With Quote
  #10  
Old 09-14-2009, 09:12 AM
  ElegantXMods.com's Avatar 
ElegantXMods.com ElegantXMods.com is offline
 

Advanced Member
  
Join Date: Apr 2009
Location: Stirling, UK
Posts: 94
 

Default Re: Email cart contents?

Any luck with this?

I'm sure it's just a typo - did you manage to add error reporting to the page?
__________________
John
ElegantXMods.com

QuickOrder AJAX-based search and ordering system now available
giving you complete control over how customers browse and search for your products. Click here for details.
PriceSlider - easily filter categories by price range - only $9.99 - details here

X-Cart 4.1, X-Cart 4.2 on Windows/IIS and Linux/Apache.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 10:20 AM.

   

 
X-Cart forums © 2001-2020