Email Notification when a new customer has been added - Magento

后端 未结 7 1033
鱼传尺愫
鱼传尺愫 2021-01-03 06:31

I would like to send an email notification to my store\'s contact email address every time when a new customer has been Registered.

I don\'t want to purchase any kin

7条回答
  •  被撕碎了的回忆
    2021-01-03 07:22

    As an alternative to an event based approach, you could run a separate API based script to fetch new (or updated) customers and email them to you, it may or may not be desirable for you to get a once-per-day list rather than an email for every single customer too.

    Benefits:

    • Nothing installed in your Magento store
    • Does not add any extra processing or network delays to a new/updated customer operation
    • Opportunity to batch all emails for a day into one email

    Here's an example I used recently which is almost exactly what you want, which is why this caught my eye. Code is available here.

    $client =
       new SoapClient('http://www.yourstore.com/magento/api/soap?wsdl');
     $session = $client->login('TEST_USER', 'TEST_PASSWORD');
    
     $since = date("Y-m-d", strtotime('-1 day'));
     // use created_at for only new customers
     $filters = array('updated_at' => array('from' => $since)); 
    
    
     $result = $client->call($session, 'customer.list', array($filters));
    
     $email = "New customers since: $since\n";
    
     foreach ($result as $customer) {
             $email .= $customer["firstname"] ." ".
                         $customer["lastname"] . ", " .
                         $customer["email"] . "\n";
     }
    
    mail("customer-manager@yourstore.com", "Customer report for: $since", $email);
    

提交回复
热议问题