WooCommerce Hook before "New Order"-Mail is sent - php

During my WooCommerce order, the user selects an image that gets uploaded to the server. Now I need to edit this image (resize, trim etc. with ImageMagick) BEFORE the "new Order" emails are sent, because I attach this image to these emails.
I tried the payment_complete hook, but this one is too late, the mails are already sent. I also thought about doing it in the mail templates, but it only needs to be done once, so it has to especially be before the mails are sent out.
Of course it should happen on the server after the "thank you" page, the user shouldn't have to wait for this processing.
Edit: The hook should deliver the order id because I need to access the order items.
Where can I insert/hook my code to achieve this?
Thank you!

Well the new order emails are triggered to run on the woocommerce_order_status_pending_to_processing_notification and woocommerce_order_status_pending_to_on-hold_notification hooks, with default (10) priority.
Therefore, you should be able to run your code on the same hooks with a lower priority (say, 5).
Failing that, you could skip the notification and just focus on the order status change, so the following hooks:
woocommerce_order_status_pending_to_processing and woocommerce_order_status_pending_to_on-hold

Related

Delay WooCommerce order processing mail

I have a question regards delaying a WooCommerce Out of the box email notifications. We use WooCommerce Shipment tracking and also Dokan plugins. And therefore we also have suborders: A suborder has also a tracking code. We provide that information in the parent order processing mail.
When a new order comes in, the shipment tracking is empty. I guess this is because the mail is sent too fast. I think this because of the reason, that when I send the processing mail from the admin backend manually, then I have all info. So the code is fully working. I only have the problem with the automatically sent mail from WooCommerce when a new order comes in.
I found this but there is no time delay: Send an Email notification to the admin for pending order status in WooCommerce
Also, I found this plugin code on Github from Damien Carbery.
But I don't know if I can just copy the code and make changes to it?
This is the part that I should change maybe:
'woocommerce_order_status_pending_to_processing' => array( 'WC_Email_New_Order', $this->default_defer_time ),

Deactivate sending of certain mails in Shopware 5

For a shop we need to deactivate most of Shopware's default mails, such as order confirmation, bill, etc. The only ones we need to keep are the ones about user management (profile created, forget password).
I found this answer that shows how to disable all mails.
But nothing else, searched SO, Shopware forum (German and English), a lot of people having the same need but no solution posted anywhere.
You can deactivate the order confirmation email in backend using the "send order mail" field under the checkout settings like described in the documentation.
Most of the other emails are triggered manually on e.g. order status change or cron jobs.

Woocommerce Order Completed Email notification

I am trying to find a way to send out an email once the order has been completed within WooCommerce store. How would I go about sending an auto email once the product/order has been ticked finish.
Thanks
WooCommerce automatically send the processing email to user when you place any order and also send the mail to admin for new order you have to do nothing. Are you getting any type of error or something? because after installation all thing works automatically.

PayPal "Thank you" page, with details

I'm working on setting up a page that will display some information to the end-user after they make a purchase through PayPal. This page will have quite a few different tasks that it will need to execute to ensure the user receives what they had paid for, this mostly includes displaying information for the user in-case something goes seriously wrong, for example: The email containing product information is never sent.
In this event I would like to instruct the user to fill out "X" form providing their custom transaction id, however I don't know how I'd pass that custom transaction id to the thank-you page from paypal.
I know how to use the IPN, and I'm rather familliar with it. I've always used it to send emails, etc; However here, considering I'm selling a virtual product, I need to make sure it's delivered automatically, and providing enough information so that any problems can be dealt with accordingly.
IPN itself is all you need. You can generate email notifications with a download link or an attachment of the digital item that you're selling and it will be delivered in real-time. It will also help you handle things like e-checks correctly so that the goods aren't delivered until the payment actually clears as opposed to when the first transaction (the pending e-check) comes through.
If you do want to display data on the thank you page (assuming you're working with Payments Standard) then you can use PDT, which is very similar to IPN except that it's intended to send data back to the thank you page. This is for display purposes only and is not recommended to be used for updating the database, sending emails, etc.
Yet another option would be to move to the Express Checkout API. That way the checkout flow will always finish on your site without setting up any auto-return or PDT features, and you can do whatever you need to do in the thank you page code very easily. Again, though, it's still recommended to use IPN for final post-payment processing so that you can handle things like pending payments.

WordPress plugin with e-mail mass sending

I'm currently making a promotion plugin for WordPress where I need to send out e-mails to different press e-mails based on a checkbox-list. My hosting provider has a limit of 200 e-mails/hour, but I don't think I will reach that limit. I know that mailing list providers are recommended, but my plugin has some functions (like making promo codes etc.). Everything is now finished with the plugin, and I only need the function for sending.
I have been searching for solutions, and have been looking at timers in PHP to avoid spam detection. I think I will end up with Cron jobs. I have looked into the built in WordPress cron job function, and will try to use this one.
I have never been using cron jobs before, so my questions is: how can I keep track on which e-mail my plugin has sent to? Do I need a temp table where each row is deleted when sent?
Any other suggestions for my solution would be appreciated!
if(mail(//params))
{
//insert this email id in db
}
you can keep track by inserting email id in to db if email sent successfully.

Categories