Jump to content
Sign in to follow this  
teamkenb

Some emails to customers being sent twice

Recommended Posts

I just noticed that my customer email confirmations and abandoned cart emails are being sent to the customer twice?
The order complete emails to the customer and emails to admin are fine. From the logs it looks like this has been happening for the last couple of weeks. Nothing changed that I know of.
Any idea what the problem could be?

All products are physical, no digital products.
 

Share this post


Link to post
Share on other sites

I don't have an immediate answer, but please confirm that you know these emails are getting sent twice and both received by the recipient - as opposed to only getting logged in the Email Log twice.

Share this post


Link to post
Share on other sites

Yes both are being received by the customer, that is how we became aware of this issue. Customers were concerned that they were placing 2 orders(even though the order # is the same)

I have tested it several times and do receive the order confirmation email twice.

Share this post


Link to post
Share on other sites

Also, are each pair being sent at the same time?

Would you be using the Print Order Form gateway module?

Share this post


Link to post
Share on other sites

They are being sent anywhere from 3 to 5 seconds apart.

I do have the Print Order Form and USA Print Order Form modules available but they are not active, I have not used them.

Share this post


Link to post
Share on other sites

I deleted those Print Order extensions and I am still getting the 2 confirmation emails.

I am using CC version 6.2.8

 

Share this post


Link to post
Share on other sites

I will formulate some tests to see if we can determine what is triggering the emails.

Share this post


Link to post
Share on other sites

I've see this, but I can't find any reference on the forum.

I seem to think it might have been related to:  Store Settings > Features > Force Order Completed Emails.

An email is sent intitally when the status changes to pending or processing (which ever you have selected),

And then another is sent when the status changes to complete.

Share this post


Link to post
Share on other sites

It is sending the Order Confirmation email twice, the exact same email twice within seconds of each other.

When I process the order and mark it complete it sends the Order Complete email as it should.

Share this post


Link to post
Share on other sites

We will create a code snippet.

For each email sent, this will log a debug trace in CubeCart's System Error Log. A debug trace is a list of every PHP script that was involved when the debug command was executed.

In admin, Manage Hooks, Code Snippets tab, click Add Snippet.

When the next page shows up, fill in the form at the bottom:

Enabled: checked
Unique ID: [email protected]
Execution Order: 99
Description: Logs a stack trace to the Error Log when sending emails.
Trigger: class.mailer.presend
Version: 1.0
Author: https://forums.cubecart.com/topic/55651-some-emails-to-customers-being-sent-twice/
PHP Code:
<?php
if (!function_exists('generateCallTrace')) {
function generateCallTrace(){
    $e = new Exception();
    $trace = explode("\n", $e->getTraceAsString());
    $trace = array_reverse($trace); // reverse array to make steps line up chronologically
    array_shift($trace); // remove {main}
    array_pop($trace); // remove call to this method
    $length = count($trace);$result = array();
    for ($i = 0; $i < $length; $i++) $result[] = ($i + 1)  . ')' . substr($trace[$i], strpos($trace[$i], ' '));
    return "\t" . implode("\n\t", $result);
}
}
$GLOBALS['debug']->errorLogger('Trace',"Sending an email:\n".generateCallTrace(),__FILE__,__LINE__);

When you next notice an email having been sent twice, examine the System Error Log in CubeCart's admin.

The contents of each log entry will be in one single line, so you will need to copy it and split it apart in a text editor.

 

Edited by bsmither

Share this post


Link to post
Share on other sites

There are 2 errors 2 seconds apart:

#1

[<strong>Unknown (Trace)</strong>] /home/abminfoabm/public_html/cart/includes/extra/snippet_72a41b86017c796b2b1df30b98ac9db6.php:14 - Sending an email: 
1) /home/abminfoabm/public_html/cart/index.php(20): include('/home/abminfoab...') 
2) /home/abminfoabm/public_html/cart/controllers/controller.index.inc.php(89): Cubecart->loadPage() 
3) /home/abminfoabm/public_html/cart/classes/cubecart.class.php(445): Cubecart->_gateway() 
4) /home/abminfoabm/public_html/cart/classes/cubecart.class.php(2139): Cubecart->_displayGateways('Card_Capture') 
5) /home/abminfoabm/public_html/cart/classes/cubecart.class.php(1961): Gateway->form() 
6) /home/abminfoabm/public_html/cart/modules/gateway/Card_Capture/gateway.class.php(212): Gateway->process() 
7) /home/abminfoabm/public_html/cart/modules/gateway/Card_Capture/gateway.class.php(106): Order->orderStatus(2, '200123-032949-9...') 
😎 /home/abminfoabm/public_html/cart/classes/order.class.php(517): Mailer->sendEmail('[email protected],...', Array) 
9) /home/abminfoabm/public_html/cart/classes/mailer.class.php(231): include('/home/abminfoab...')

 

#2

[<strong>Unknown (Trace)</strong>] /home/abminfoabm/public_html/cart/includes/extra/snippet_72a41b86017c796b2b1df30b98ac9db6.php:14 - Sending an email: 
1) /home/abminfoabm/public_html/cart/index.php(20): include('/home/abminfoab...') 
2) /home/abminfoabm/public_html/cart/controllers/controller.index.inc.php(89): Cubecart->loadPage() 
3) /home/abminfoabm/public_html/cart/classes/cubecart.class.php(445): Cubecart->_gateway() 
4) /home/abminfoabm/public_html/cart/classes/cubecart.class.php(2139): Cubecart->_displayGateways('Card_Capture') 
5) /home/abminfoabm/public_html/cart/classes/cubecart.class.php(1961): Gateway->form() 
6) /home/abminfoabm/public_html/cart/modules/gateway/Card_Capture/gateway.class.php(212): Gateway->process() 
7) /home/abminfoabm/public_html/cart/modules/gateway/Card_Capture/gateway.class.php(195): Mailer->sendEmail('[email protected]', Array) 
😎 /home/abminfoabm/public_html/cart/classes/mailer.class.php(231): include('/home/abminfoab...')

 

Edited by teamkenb
#

Share this post


Link to post
Share on other sites

The first instance is the Card Capture gateway changing the order status to Processing - which sends an email to the customer.

The second instance is the Card Capture gateway having its module settings enabled for sending a confirmation email.

In the Card Capture module settings page, it is apparent that you have the setting for "Update order status to "Processing" on capture?" enabled, even though you do not know if the card can be transacted. That's up to you, of course. It is also apparent that you have the setting for "Send order confirmation email?" enabled, as if, since the order should stay at pending until transacted, you wish to have CubeCart send an email summarizing the order. (CubeCart does not send an email to the customer on orders that are Pending.)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...