Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Send email x-days after purchase
 
Gui
Guru
 
Avatar
Total Posts:  588
Joined:  2008-03-09
 

This template could be used for a variety of things. It is very usefull for asking customers to review their product.

 
Magento Community Magento Community
Magento Community
Magento Community
 
magentazm
Jr. Member
 
Total Posts:  29
Joined:  2010-01-31
 

Hope this helps others.

Here is a cron you can run daily with something like:

0 0 * * * /usr/bin/wget -q -O /dev/null http://www.yourstore.com/path/to/script

It will pull both Magento and Guest (Eg: From PayPal Express checkout) orders out.

Put it in your root directory and/or secure it appropriately.

Tested with 1.6.2 Community.

<?php
// Start Magento Classes
require_once 'app/Mage.php';
umask(0);
Mage::app();

// Pull in the entire list of orders
$orders Mage::getModel('sales/order')->getCollection()->addAttributeToSelect("*");

// Loop for each order
foreach ($orders as $order){
    $orderTime    
strtotime($order->getCreatedAt());

    
$toEmail    $order->getCustomerEmail();
    
// If you use PayPal checkout express, it will be a guest user, so we pull the email from the billing instead
    
if (!$toEmail{
        $toEmail 
$order->getBillingAddress()->getEmail();
    
}

    $firstName 
$order->getCustomerFirstname();
    
// If you use PayPal checkout express, it will be a guest user, so we pull the name from the billing instead
    
if (!$firstName{
    $firstName 
substr($order->getBillingAddress()->getName(), 0strpos($order->getBillingAddress()->getName(), " "));
    
}


    
// Create a list of different countries in order to standardize when a certain country should be emailed
    
$country $order->getShippingAddress()->getCountry();
    
$domestic_countries = array('US''CA');
    if (
in_array($country$domestic_countries))
        
$domestic TRUE;
    else
        
$domestic FALSE;
    
$days_ago intval((time() - $orderTime) / 86400);

    
// Depending on how long items take to arrive, decide on how long to wait to send the follow up email
    
if (($domestic && $days_ago == 14) || (!$domestic && $days_ago == 42)) {

    $body 
"Hello $firstName!\r\n\r\nThank you for your recent purchase.  Please blah blah blah";
    
$body wordwrap($body65);

    
// Uncomment these lines if you would like to see what is going to be sent
    //echo "<h2>$country order for $firstName at ".$order->getCreatedAt()."</h2>";
    //echo "Was going to email this to $toEmail:\n\n$body\n\n";

    
$subject "$firstName, you ordered from us recently";
    
$fromEmail 'sender@email.com';
    
$fromName 'The sender name';

    
// If you are using an SMTP relay, put the details in here
    
$config = array(
    
'username' => '',
    
'password' => '',
    
'port' => 25
    
);

    
$transport = new Zend_Mail_Transport_Smtp('localhost'$config);
    
$mail = new Zend_Mail();
    
$mail->setBodyText($body);
    
$mail->setFrom($fromEmail$fromName);
    
$mail->addTo($toEmail$firstName);
    
$mail->setSubject($subject);
    
$mail->addBcc('you@yourserver.com''Your name');
    
$mail->send($transport) or die ("Failed to send email");

    
}
}
?>
End
.
]
 
Magento Community Magento Community
Magento Community
Magento Community
 
carlitagoldm
Jr. Member
 
Total Posts:  2
Joined:  2013-09-17
 

Hello,
Take a look at this extension http://mirasvit.com/magento-extensions/sales-motivation/follow-up-trigger-email-suite.html

The extension allows you to solve the following tasks:
* to turn the potential customers into buyers
* to remind on the abandoned cart
* to do the cross-sell based on the previous sales
* to remind of yourself the old customers who have not visited your site for a long time
* to offer a discount
* to remind customers of the need to re-order (for example, if you sell consumables)
* to congratulate on birthday or other celebration
* to maintain good relationship with customers, to increase their loyalty

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top