SMF Shop
SMFShop => Coding => Topic started by: samurai-lupin on April 14, 2007, 12:17:59 am
-
Hello!
I would like to modify my Shop 3.0 code so that it sends me an e-mail whenever someone purchases an item from my store.
If anyone knows how to modify the code for this purpose please kindly let me know.
Best wishes,
Christian
-
So, when someone buys an item, you want an email?
In Sources/shop/Shop-Buy.php, find:
// Tell them that they purchased it
$context['shop_buy_message'] = sprintf($txt['shop_bought_item'], $row['name']);
Add above:
// Modified as per http://www.daniel15.com/forum/index.php/topic,784.0.html - Send an email on purchase of an item
// We need the sendmail() function
global $sourcedir;
require_once($sourcedir . '/Subs-Post.php');
// Who are we sending to?
$to = 'i_like_spam@daniel15.com';
// Subject of the email
$subject = '"' . $row['name'] . '" item bought';
// Actual message
$message = 'The user ' . $context['user']['name'] . ' has purchased a ' . $row['name'] . 'item.';
// Send it!
sendmail($to, $subject, $message);
Change the email address, subject and message to suit your needs. Even if you don't know PHP, you should be able to see what the code is doing :) ($row['name'] is the name of the item).
-
Thank you very much Daniel! I really appreciate it!
-
So, when someone buys an item, you want an email?
Hello,
this works great!!!
Is it also possible to send this email to 2 addresses? And what do I need to change for that?
Thanks,
Vincent.
-
This might work:
Change
$to = 'i_like_spam@daniel15.com';
to
$to = 'i_like_spam@daniel15.com, some_other_spam_address@daniel15.com';
(ie. separate the addresses by a comma). Please tell me if this works, I haven't tested it.
-
This might work:
Change
$to = 'i_like_spam@daniel15.com';
to
$to = 'i_like_spam@daniel15.com, some_other_spam_address@daniel15.com';
(ie. separate the addresses by a comma). Please tell me if this works, I haven't tested it.
Sorry for the delay, didn't get an e-mail of the replay :(
the above is nog working correct, the e-mail is send to the first e-mail address only.
Vincent.