- Posts: 7
- Thank you received: 0
Sending customer email when updating order status
- turfymurphy
-
Topic Author
- Offline
-- Joomla version -- : 3.8.8
-- PHP version -- : 5.6
-- Error-message(debug-mod must be tuned on) -- : No errors
I would expect this to send an email to the customer? But no emails are being sent (they do not appear in the customer emails history).
If I change it manually through the shop then it works when I tick (notify customer).
Any advice?
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
Can you check that the "Order status notification" email is published via "Hikashop->System->Emails" ?
Thank you.
Please Log in or Create an account to join the conversation.
- turfymurphy
-
Topic Author
- Offline
- Posts: 7
- Thank you received: 0
Yeap it is published. Emails work fine when setting the status manually but not through the php script.
Please Log in or Create an account to join the conversation.
Can you check that your order have switch to a confirmed status ?
If not, maybe the issue isn't starting with Email processing but with Payment method or Order status configuration or the way you process your test (like a payment method isn't able to switch status on localhost or else...)
The logical chain is like this :
1° Payment servers send notifications => 2° Payment method switch the order status (if configuration fit this and order had succeed) => 3° HikaShop switch the Order statuts => Email is sent.
Hope this will help you to move forward.
Regards
Please Log in or Create an account to join the conversation.
- turfymurphy
-
Topic Author
- Offline
- Posts: 7
- Thank you received: 0
Thank you for the reply
I'll explain a bit more on the process at the moment.
Order gets created and updates to 'Confirmed' when paid for (all works fine, emails are sent etc..)
Plugin is hooked on onAfterOrderUpdate and gets the orderId and cURL posts it to another script (script pulls full order, formats a new object to how I need it with the order details and posts it off site) Does not make any changes or updates to the order
Another script is setup to basically update the orders status:
It loads the full order and makes a change to the status if required.
Everything works perfectly fine, script changes order status to 'Shipped' - adds tracking ID to the history etc all updates and reflects on the system.
The only thing it is not doing is sending the email to say 'You're order is now shipped' etc.
// Edit
Just to add to this, the hikashop_history table is updating correctly, showing new_status = shipped and notified = 1
Thanks
Please Log in or Create an account to join the conversation.
Ok, so do you get the email that should be sent in the "Customer>Emails history" section of the shop ?
Also, in the trigger onAfterOrderUpdate, the second parameter $send_email can be set to false to prevent the sending of the notification.
So make sure that you're not doing that.
In fact, you could even force that variable to true in order to see if you correctly get the email or not.
Please Log in or Create an account to join the conversation.
- turfymurphy
-
Topic Author
- Offline
- Posts: 7
- Thank you received: 0
There are no entries in the Emails History for that order (for the status modification) the normal create/confirmed are there but not my update.
$send_email is not used at all in the plugin, so I assume default of true?.
I'll try and force it to true.
Is there any manual way I can send the email? I have read some threads about the mail class and loading a notification?
Please Log in or Create an account to join the conversation.
Default is the value of $orderObj->history->history_notified, and any plugin integrating with onAfterOrderUpdate can change it.
You should be able to use something like that:
Please Log in or Create an account to join the conversation.
- turfymurphy
-
Topic Author
- Offline
- Posts: 7
- Thank you received: 0
The actions I am taking on updating the order etc do not happen within a plugin, it is external.
Please Log in or Create an account to join the conversation.
As long as you load joomla and HikaShop properly before, it should work fine yes.
Please Log in or Create an account to join the conversation.
- turfymurphy
-
Topic Author
- Offline
- Posts: 7
- Thank you received: 0
I have noticed that when I put the ->sendMail code inside the plugin it works and sends two emails! (Don't really understand why two).
Is this all I need to work with the hikashop? loadFullOrder etc all works fine but am I missing something that stops the emails/notifications from being sent?
Above code works inside plugin but not in my own script
Thanks for your help
## EDIT
I have added some logging to my file and it doesn't seem to get past this block:
Is there anything I am missing to be able to use these functions in an external file?
Please Log in or Create an account to join the conversation.
I did a test on my end with that code:
The Joomla code comes from: www.simbunch.com/blog/141-instantiate-in...n-an-external-script
Please Log in or Create an account to join the conversation.
- turfymurphy
-
Topic Author
- Offline
- Posts: 7
- Thank you received: 0
Please Log in or Create an account to join the conversation.