Troubleshooting Customers Email Order Notification

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334271

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.9.28
-- PHP version -- : 7
-- Error-message(debug-mod must be tuned on) -- : No Errors

Hello,

I'm getting reports that some of my customers are not getting their email order notifications after checkout. They have confirmed that the message is not in their spam folder as well. I have noticed that HikaShop has an area in the Admin, under Customers -> Email History. There I can confirm that there is no email history log for this customer. However I can confirm that there is an order for this customer under orders.
In this scenario, it looks like to me for some reason the email failed to be triggered to send out to the customer. I received the admin email but the customer says they didn't get theirs. This does not happen all of the time. It seems to be random occurrences.
I was wondering if I can assume that if the email history log doesn't show an email was sent here, then is it safe to assume something failed and the site didn't ever send that email? If this is the case, any ideas as to what may cause this?
I'm using SMTP to send email from the website and I can confirm that there doesn't seem to be any record in the SMTP providers logs either.
Any thoughts? I'd like to know if there is any where else I can try to look to uncover the issue before I assume that the message "sending" failed on the website and never was triggered to begin with after the purchase.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334293

Hi,

Checking the Email history is indeed the first thing to do.
If you don't see the notification email for all your customers there, then the most likely cause is that the email is unpublished in the System>Emails menu. Otherwise, it could also be a bug somewhere.
If it happens only for some users, then it must be a bug somewhere.
Was the status of the order changed ?
If not, then it's probably linked to the payment plugin.
If yes, do you have a "automatic payment notification" in the history of the order ?
Also, supposing that it comes from a bug which stops the processing of the page where the email is supposed to be sent, the PHP fatal error message corresponding to the issue should be logged in the PHP log file of your hosting. So I would recommend to check it. The most likely thing is that the email has been customized generating sometimes an error, or that there is a custom plugin or third party plugin generating an error. So checking the PHP error log could yield interesting information on the issue.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334299

Hello Nicolas,

I do see this particular error message from the logs corresponding with orders but I'm not clear if this is actually the problem. But it appears to be complaining of something related to the payment notification. I have copied the source of the mentioned file below the log snippets. Any thoughts?
-- Log Snippets --
[Wed Jul 07 12:01:43.949286 2021] [fcgid:warn] [pid 15879] [client 128.193.8.40:61772] mod_fcgid: stderr: PHP Notice: Undefined property: stdClass::$order in /home/ravescientific.com/public_html/media/com_hikashop/mail/payment_notification.text.php on line 12, referer: ravescientific.com/my-rave/checkout/checkout/cid-5
[Wed Jul 07 12:01:43.949385 2021] [fcgid:warn] [pid 15879] [client 128.193.8.40:61772] mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /home/ravescientific.com/public_html/media/com_hikashop/mail/payment_notification.text.php on line 12, referer: ravescientific.com/my-rave/checkout/checkout/cid-5
-- End Log Snippets --

-- Source of payment_notification.text.php ---

<?php
/**
 * @package     HikaShop for Joomla!
 * @version     3.4.0
 * @author      hikashop.com
 * @copyright   (C) 2010-2018 HIKARI SOFTWARE. All rights reserved.
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php echo JText::sprintf('HI_CUSTOMER',@$data->customer->name)."\n"."\n";?>
<?php
$url = $data->order->order_number;
if($config->get('simplified_registration',0) != 2) {
        $url .= "\n".'( '.$data->order_url.' )'."\n";
}
echo JText::sprintf('ORDER_STATUS_CHANGED_TO',$url,$data->mail_status)."\n"."\n";?>
<?php echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER',HIKASHOP_LIVE)."\n"."\n"."\n";?>
<?php echo str_replace('<br/>',"\n",JText::sprintf('BEST_REGARDS_CUSTOMER',$mail->from_name));?>

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334303

Hi,

That's strange. This indicates that the "payment notification" email is sent by HikaShop at the end of the checkout.
With most payment plugins, this email is sent when the payment notification is received from the payment gateway server and so the URL ravescientific.com/my-rave/checkout/checkout/cid-5 in the warning message should be something else.

So now, I'm thinking about something else:
HikaShop sends two emails to the customer for an order:
- the order creation notification which is sent when the order is created
- the order status notification which is sent when the order status is changed in a payment notification
So what I'm thinking is that you might have disabled the "order creation notification" email, but you have a payment plugin which processes the payment at the creation of the order, and thus the order is directly created confirmed and thus only the "order creation notification" email would be sent if it was activated. And thus, in that case, the customer would receive no email.

Supposing that I'm on the right track here, we're not talking about a bug but more of a configuration issue between the emails and how the payment plugins you're using work. Could you tell us more about which payment plugin you're using ? Did you notice that the emails are sent or not based on the payment method used ? And when you say that you see the user email in the email history, are you talking about the "order status notification" or the "order creation notification" ? Did you disable the "order creation notification" email ?

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334369

We are using the Authorize.net payment plugin. It looks like perhaps the issue might be specific to this payment method. We also use the purchase order payment method and a collect on delivery payment method, which appear to not be having the issue.

Regarding the setting of the emails, I can confirm that the "order creation notification" is not disabled neither is the "order status notification" It appears that the emails in the history log are "order creation notification" that show for the customer when successful. It looks like when a alternate payment method like purchase order is used, then both the "order creation notification" and "order status notification" emails will be used.
It appears that on the administrator side, the email is always working and not having an issue. It looks like the "order administrator notification" and the "payment notification payment" emails are triggered and recorded in the email history log for the administrator.

The specific configurations on the Authorize.net plugin are as follows:
---
URL: secure.authorize.net/gateway/transact.dll
Authorize Signature Key: blank
MD5 response: blank
Instant Capture: Yes
Duplicate Window: blank
Allow payment notifications from Authorize: Yes
Send details of the order: Yes
API: AIM
Card validation Code: Yes
Enable Validation mode: No
Test Payments: No
Debug: No
Return URL: order-status
Your logo URL: blank
Negative Coupon value: No
Invalid Status: canceled
Pending Status: created
Verified Status: confirmed
---

Hopefully I provided a clear idea of what seems to be happening. Let me know if you need any more info or have any questions. Thanks in advance!

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334374

Hi,

What you're saying all seems normal.
To recapitulate, you said in your first message that you're

getting reports that some of my customers are not getting their email order notifications after checkout.

.
But you're saying that the emails do appear in the Email history in your last message

It appears that the emails in the history log are "order creation notification" that show for the customer when successful. It looks like when a alternate payment method like purchase order is used, then both the "order creation notification" and "order status notification" emails will be used.

That's in contradiction to what you said in your first message

I have noticed that HikaShop has an area in the Admin, under Customers -> Email History. There I can confirm that there is no email history log for this customer.


If the email to the customer is in the email history, then HikaShop sent it to the email server. In that case, the email probably ended up being treated as spam. While some emails end up in the spam folder when that's the case, some are just deleted by the receiving email server. So the fact that the email is not seen by the customer in their spam folder, doesn't mean that the email was not sent by your website. It could just be that the email was rejected on the customer's end. supposing that we're in that case, you should check your emails with www.mail-tester.com/

If the email to the customer is not in the email history, then are you talking about the "order status notification" email for authorize.net orders ? It's normal that in AIM mode the order status notification is not sent to the customer since the order is directly created confirmed. The order status notification is only sent when the order status is changed. However, the customer should still receive the order creation notification email, which you say is logged in the email history. So I'm confused about what is your problem here and the status of the emails in your email history.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334384

Hi Nicolas,

Thanks for the quick response and I'm sorry I believe I may have confused you. But when I'm saying:

It appears that the emails in the history log are "order creation notification" that show for the customer when successful. It looks like when a alternate payment method like purchase order is used, then both the "order creation notification" and "order status notification" emails will be used.

What I mean is it does show that some are successful, some customers show their email has been sent here. However in the case of the customers that are complaining that they are not receiving their order emails, it doesn't show anything in the log for them. Neither the "order status notification" or the "order creation notification" Sorry for making that confusing in my last message.
Thank you for the detailed explanation of how the notifications work with Authorize.net.We are using SMTP to send mail, and I can confirm that there is no history of emails for this case in our SMTP providers logs. If it did send out I should see some history of it in the logs of our SMTP provider. It seems like something is failing and not triggering the email to be sent out during checkout process in this case. Any thoughts on this? Thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334392

Hi,

So you're saying that for some of your customers, and only for some orders, not all, using Authorize.net, no email notification appear to be sent to the customer after the order in the email history of HikaShop. Is that correct ?
Supposing that it is the case, then it's either a customization i
Could you provide a screenshot of the "history" area at the bottom of the order details page in the backend for an order with the issue ?

Also, do you have any custom plugin developed on your end on your website ? Did you configure any mass actions in the menu System>Mass actions ? Did you customize the emails in System>Emails ?

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334403

Hi,

Yes it seems that orders using the credit card payment method through Authorize.net are not triggering the "order creation notification" for the customers. The order goes through but the system does not seem to send the email to them. This never was an issue until recently and I'm not aware of any changes that would have caused this. I attached a order history screenshot of an order with the problem, I can see that there is no line for the "payment notification" only a line showing the order was confirmed and with shipping details.
Regarding custom plugins, no I don't have any setup. Also regarding mass actions there are some setup but none are set to run without manually running them. They also have been setup for a while now before this problem started to happen.
Regarding the System Emails and customizing, Yes. We did customize them but also this was done a long time ago before this problem starting happening. Nothing has changed that I'm aware of.
Not sure what the issue could be but I attached a screenshot of the order history area for a customer that didn't get the email, and I attached the customized "order creation notification" system email and the "order status notification" system email so you could have a look at the them too. Let me know what you find. Thanks.

File Attachment:

File Name: customized-emails.zip
File Size:18 KB

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334406

Hi,

If you check the code of the "save" function of the file administrator/components/com_hikashop/classes/order.php you can see this:

			$app->triggerEvent('onAfterOrderCreate', array(&$order, &$send_email));

			$historyClass->addRecord($order);

			if(!$send_email)
				return $order->order_id;

			$this->loadOrderNotification($order,'order_creation_notification');
			$mailClass = hikashop_get('class.mail');
			if(!empty($order->mail->dst_email)) {
				$mailClass->sendMail($order->mail);
There, the line
$historyClass->addRecord($order);
is responsible for adding the line you can see on your screenshot in the history area. So that means that the code run up until there.
And the line
$mailClass->sendMail($order->mail);
is the one sending the order creation notification email.
In between, there is not much, so the list of causes is:
- the $send_email is set to "false" by a plugin implementing the onAfterOrderCreate trigger. This could be done by a custom plugin. Besides that, I don't see what would do that. I checked all the plugins in HikaShop and none change that variable.
- the email order_creation_notification can't be loaded for some reason or the $order->mail->dst_email attribute is empty. This could happen with some customization but that's about it. I checked your files and it seems ok. I would recommend you try to use the "preview" button of the order creation notification on the same order for which the email was not sent. Maybe you'll be lucky and get some clue on the problem.
- the loading of the order_creation_notification email results in a fatal error. In that case, the customer should see a blank page at the end of the checkout, and you should be able to see that fatal error message in the PHP error log of your server. So I would recommend checking there.
There is nothing else I can reasonably see which could cause the email not being sent so if the the things above don't yield any interesting information on the problem, it will be necessary to add
hikashop_writeToLog('step x');
between each lines of the code above (with a different number instead of x each time). Then, reproduce the issue once and look at the "payment log file" in the Hikashop configuration. You'll see the "step 1", "step 2", etc messages at the end and you'll see if it stops somewhere. That way, we'll know where to look.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334414

Hi,

Okay thanks for your response. No luck in finding any clues when viewing the "Preview" of an order that was a problem. The email looks fine in the preview, and nothing to reveal.


When I had searched the logs previously, the only lines I recall were ones that I provided to you prior. See below:

-- Log Snippets --
[Wed Jul 07 12:01:43.949286 2021] [fcgid:warn] [pid 15879] [client 128.193.8.40:61772] mod_fcgid: stderr: PHP Notice: Undefined property: stdClass::$order in /home/ravescientific.com/public_html/media/com_hikashop/mail/payment_notification.text.php on line 12, referer: ravescientific.com/my-rave/checkout/checkout/cid-5
[Wed Jul 07 12:01:43.949385 2021] [fcgid:warn] [pid 15879] [client 128.193.8.40:61772] mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /home/ravescientific.com/public_html/media/com_hikashop/mail/payment_notification.text.php on line 12, referer: ravescientific.com/my-rave/checkout/checkout/cid-5
-- End Log Snippets --


I'm going to try putting the log triggers you suggested into the file administrator/components/com_hikashop/classes/order.php like you suggested and see if I can get more details. I'll let you know if I can get any more info once I do that.

On another note, was wondering if by any chance the Hikashop Google Analytics plugin could cause an issue? Just a hunch but I recalled that we recently gave administrator access to the site to a third party company to do some Google Analytics / Marketing type stuff and when I think about it, it lines up approximately with around about when these issues started to pop up. So I took a look at the audit log and I can confirm that they installed and configured the Hikashop Google Analytics plugin. Any chance this could be it? I found some code in the plugin that is leveraging the event / trigger onAfterOrderCreate but I'm not clear if this is doing anything to the emails. See code snippet from the plugin below:
public function onAfterOrderCreate(&$order) {
                if(isset($order->order_type) && $order->order_type != 'sale')
                        return;

                return $this->checkOrder($order, true);
        }

        public function onAfterOrderUpdate(&$order) {
                if(isset($order->order_type) && $order->order_type != 'sale')
                        return;

                return $this->checkOrder($order, false);
        }

Any thoughts? Thanks in advance.

Last edit: 3 years 4 months ago by rjrsinc.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334418

Hi,

The Google Analytics plugin, based on how it is configured, might send a request to GA when the order is created.
So if that request takes too long, it's possible that the PHP process would stop ending in a white page. But in that case, the addRecord function wouldn't be called, and you would see an error message in the PHP error log corresponding to it.
The fact that neither happen means that it's not coming from that.
Another possibility would be that the GA plugin would change some data in $order, but I checked the code of the plugin and there is no such thing.
So all this indicates it's probably not coming from the GA plugin.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334431

Hi,

Sounds like from what your explaining the Google Analytics plugin might not be the problem but I think I'll have to take another look at the logs to be sure that I can't find anything. If the Google Analytics plugin was causing the issue, do you know what the line in the logs would likely contain? If you have any details on that, it would be helpful for when I'm searching the logs.

In the meantime I'm going to try putting the log triggers you suggested into the file administrator/components/com_hikashop/classes/order.php and see if I can get more details. I'll let you know if I can get any more info once I do that.

Thanks

Last edit: 3 years 4 months ago by rjrsinc.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334436

Hi,

I tried to add the log lines to the file administrator/components/com_hikashop/classes/order.php.

$app->triggerEvent('onAfterOrderCreate', array(&$order, &$send_email));
                        // RJR
                        hikashop_writeToLog('step 1');
                        $historyClass->addRecord($order);
                        // RJR
                         hikashop_writeToLog('step 2');
                        if(!$send_email)
                        // RJR
                         hikashop_writeToLog('step 3');
                                return $order->order_id;
                        // RJR
                         hikashop_writeToLog('step 4');
                        $this->loadOrderNotification($order,'order_creation_notification');
                        // RJR
                         hikashop_writeToLog('step 5');
                        $mailClass = hikashop_get('class.mail');
                        // RJR
                         hikashop_writeToLog('step 6');
                        if(!empty($order->mail->dst_email)) {
                        // RJR
                         hikashop_writeToLog('step 7');
                                $mailClass->sendMail($order->mail);
                        // RJR
                         hikashop_writeToLog('step 8');
                                $mailClass = hikashop_get('class.mail');
                        // RJR
                         hikashop_writeToLog('step 9');
                        }

However when running a test transaction and looking at the payment log file at Configuration -> System -> Main -> Files. It is not showing any recent logging details. Is there somewhere that this can be turned off or on? I tried creating a new file and updating the reference here to it but it seems that nothing is being written to it.

Also I'm going on a hunch still but I think there is still some connection between this error and the Google Analytics plugin. I believe this because I had a copy of the site that I was able to test transactions and confirm email flowing and it didn't have the email problem. Then when I enabled the Google Analytics plugin on this copy of the site, I surprisingly recreated the error. Any thoughts on this? Is it possible that something could be conflicting?

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334438

Hi,

1. It would probably be an error message starting with "Fatal error" in your PHP error log.

2. You need to remove the

hikashop_writeToLog('step 3');
as it's between the if and the next line so it changes the behavior of the code.

3. I don't see any reason the "step 1" wouldn't appear in the log. It's before the addRecord call, which we know is done since it appears on the history section of the order.
One possibility is that you have some opcache mechanism on your hosting and thus your server was still using the previous version of the order.php file during your test. If you have it activated, you might want to temporarily turn if off:
stackoverflow.com/questions/21556437/dis...-opcache-temporarily

4. Regarding the GA plugin, how about turning it off temporarily and doing another test on your live website to see if it helps ?
Turning off that plugin will just prevent the ecommerce data from being sent to GA for new orders while it's turned off, so it's not that much of a problem doing that.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334440

Hi,

No opcache. I corrected the logging for the order.php file,

 $app->triggerEvent('onAfterOrderCreate', array(&$order, &$send_email));
                        // RJR
                        hikashop_writeToLog('step 1');
                        $historyClass->addRecord($order);
                        // RJR
                        hikashop_writeToLog('step 2');
                        if(!$send_email)
                                return $order->order_id;
                        // RJR
                        hikashop_writeToLog('step 4');
                        $this->loadOrderNotification($order,'order_creation_notification');
                        // RJR
                        hikashop_writeToLog('step 5');
                        $mailClass = hikashop_get('class.mail');
                        // RJR
                        hikashop_writeToLog('step 6');
                        if(!empty($order->mail->dst_email)) {
                        // RJR
                        hikashop_writeToLog('step 7');
                                $mailClass->sendMail($order->mail);
                        // RJR
                        hikashop_writeToLog('step 8');
                                $mailClass = hikashop_get('class.mail');
                        // RJR
                        hikashop_writeToLog('step 9');
however I'm still not getting any results in the payment log in hikashop. Do you know if there is something that could prevent the log file from being created by hikashop? Like I said previously I created a new "log" file manually and updated the reference in the configuration to it but it seems that Hikashop is not logging to the file. I also turned on debug and error reporting to maximum in case that had something to do with it.

On another note I tried disabling the Google Analytics plugin on the test site and tested a transaction but actually it seems the problem is now persisting with the plugin disabled. So I don't have faith that disabling it on the live site it is the resolution and don't have a simple way of testing the live site while its live if I was to disable it.

Any idea on why I can't get the hikashop payment log functioning? Thanks in advance.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334454

Hi,

If the path specified in the payment log file setting is invalid or non writable, it could lead to the log not being added.
I don't see anything else.
Supposing that it doesn't come from the payment log file's path being invalid or non writable, I can only think that you're not looking at the file of the correct website or something. To check on that, you can add a line with the code

echo 'correct place'; exit;
after the first writeToLog call. That will display a blank page with the text "correct place" at the end of the checkout, when the order is created, just after the log is written in the payment log file.
If you don't see the blank page, you're not editing the correct PHP file or the PHP file was cached with something like opcache.
If you do see the blank page, then you're modifying the correct place and it's taken into account by the server, but HikaShop is not able to write in the log file.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 0
3 years 4 months ago #334468

Hi,

Okay so after adjusting the file permissions on the order.php file I was able to successfully get Hikashop to write to the log to the file. Here is what the log revealed.

07.15.21 08:29:32

step 1
07.15.21 08:29:32

step 2
07.15.21 08:29:32

step 4
07.15.21 08:29:32

step 5
07.15.21 08:29:32

step 6
07.15.21 08:29:32

step 7
07.15.21 08:29:34

step 8
07.15.21 08:29:34

step 9

The interesting thing here is that I tested the transactions again with the Google Analytics plugin disabled and I wound up receiving all of the emails, payment notification to the admin, order creation notification to the user, and order administrator notification to the admin. And you can see what was logged above during that transaction. Looks like nothing but time stamps.

Then when I enabled the Analytics plugin and tested the transaction, once again the email issues happened again. Only receiving the payment notification to the admin. But no order creation notification to the user. Also what is interesting nothing is being added to the Hikashop payment log, like we never reach the function with the logging (steps x) lines I added to order.php.

Also I attached a screenshot of the order history for a transaction that didn't send the users order creation notification email. You can see we have no history.

Any thoughts on this? Thanks in advance.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
3 years 4 months ago #334471

Hi,

If you don't see anything in the log file but the logging is working, then it's normal that the history is empty.
I would recommend to add a writeToLog before the line

$app->triggerEvent('onAfterOrderCreate', array(&$order, &$send_email));
too.
That way, if you see the log from that first call to writeToLog and not the ones after in your log file, it will confirm that it comes from a plugin implementing the onAfterOrderCreate trigger. However, in that case, it means you should normally have a Fatal error logged in your PHP log file which will indicate where the problem comes from and you should see a blank page at the end of the checkout instead of your thank you page.
Also, supposing that we're in this case, what you can do is download all the folders/files under the "plugins" folder of your Joomla, and search on all the files for the text "function onAfterOrderCreate" (you can do so for example with notepad++: www.ybierling.com/en/blog-officeproducti...olersnotepadplusplus ). That will give you a list of potential culprits. Then, you can reproduct the issue, each time disabling one of the plugins in that list.
Once you find the one that is causing the issue, you can open its main file, and in the function onAfterOrderCreate, you can add writeToLog calls to see where it stops.

However, if we're not in this case (you don't have anything in the log even with the writeToLog call before the triggerEvent), then I'm not sure what's going on. Since you have the products added to the order, you must reach the line
$historyClass = hikashop_get('class.history');
in the save function of order.php
And thus there is no reason the first writeToLog before the triggerEvent call wouldn't be done.

Please Log in or Create an account to join the conversation.

Time to create page: 0.093 seconds
Powered by Kunena Forum