SMF Shop

SMFShop => Coding => Topic started by: samurai-lupin on April 14, 2007, 12:17:59 am

Title: Confirmation Mail after Item Purchase
Post 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
Title: Re: Confirmation Mail after Item Purchase
Post by: Daniel15 on April 14, 2007, 01:22:54 pm
So, when someone buys an item, you want an email?

In Sources/shop/Shop-Buy.php, find:
Code: (php) [Select]
// Tell them that they purchased it
$context['shop_buy_message'] = sprintf($txt['shop_bought_item'], $row['name']);

Add above:
Code: (php) [Select]
// 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).
Title: Re: Confirmation Mail after Item Purchase
Post by: samurai-lupin on April 15, 2007, 12:09:22 pm
Thank you very much Daniel! I really appreciate it!
Title: Re: Confirmation Mail after Item Purchase
Post by: Vincent Volmer on March 08, 2008, 08:56:25 pm
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.
Title: Re: Confirmation Mail after Item Purchase
Post by: Daniel15 on March 22, 2008, 11:54:45 am
This might work:
Change
Code: [Select]
$to = 'i_like_spam@daniel15.com';
to
Code: [Select]
$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.
Title: Re: Confirmation Mail after Item Purchase
Post by: Vincent Volmer on April 06, 2008, 11:36:00 pm
This might work:
Change
Code: [Select]
$to = 'i_like_spam@daniel15.com';
to
Code: [Select]
$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.