Jump to content

Some emails to customers being sent twice


teamkenb

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.
 

Link to comment
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.

Link to comment
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.

Link to comment
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: traceEmail@cubecart6
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.

 

Link to comment
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...')

 

Link to comment
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.)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...