• Resolved maorb

    (@maorb)


    Hi,

    I have one product in a WC shop that I need to notify by mail to another email address after this product is being purchased.

    I’ve seen a lot of threads and posts over the web about a WC filter hook named “woocommerce_email_recipient_new_order”.

    Is this filter still relevant?

    If not – what is please the correct filter hook I shoud use after a product is being purchased, in order to add a specific email address to notify?

    Thanks

    • This topic was modified 1 year, 3 months ago by maorb. Reason: add topic tags
Viewing 7 replies - 1 through 7 (of 7 total)
  • Saif

    (@babylon1999)

    Hello @maorb,

    Thank you for reaching out!

    There are many ways to achieve this, one way I’d do it is by triggering the action on the order received page using the woocommerce_thankyou. Then, I’d check for the product in the order and use wp_mail() to send the email. You can find a ready-to-use snippet for the first part at https://www.businessbloomer.com/woocommerce-check-product-id-order/.


    If you prefer avoiding custom code altogether, you can accomplish this effortlessly through the official AutomateWoo extension. This useful tool enables you to automate a variety of workflows, such as sending out emails when a customer’s credit card is nearing its expiration date or if they’ve forgotten something in their cart. I’ve included a screenshot that displays some of the preset workflows that come with the extension. You also have the power to craft your own workflows using a vast selection of triggers and actions.


    Link to image: https://d.pr/i/GPyKTv

    I suggest you give it a try (we don’t offer trials but we have a 30 day refund policy). If this extension turns out to be not what you were looking for, please reach out to us via email and we’ll be more than happy to help find alternatives. :?)

    Hope this helps!

    Thread Starter maorb

    (@maorb)

    Thanks Saif @babylon1999 for your reply!

    I want to try to avoid paid extentions for this shop, as it has no budget… Thanks for the idea of the woocommerce_thankyou action hook. I’d be happy it there’s a filter for when WC sends it mails after a new order is being completed and a default WC mail is being sent – Is there a filter in that point that I may trigger?

    10x

    • This reply was modified 1 year, 3 months ago by maorb.

    Hi there @maorb ??

    I’d be happy it there’s a filter for when WC sends it mails after a new order is being completed and a default WC mail is being sent – Is there a filter in that point that I may trigger?

    From what I gather, you are looking into notifying two separate email addresses (from the admin side of things), when an order is placed. Correct?

    Could you elaborate further on the particular needs of the workflow, please?

    For example, is this stock, or fulfillment, related, perhaps? Maybe the email can be forwarded to that other email address, along with all its contents?

    Cheers!

    • This reply was modified 1 year, 3 months ago by anastas10s. Reason: missing comma
    Thread Starter maorb

    (@maorb)

    Thanks @anastas10s for your reply.
    You’ve understood correctly.
    The workflow is that when an order is being completed (i.e. ordered and paid) for some specific products, I have to inform the product’s supplier about that purchase, so I wanted to trigger the WC filter hook on the point the mail is being sent, and there in my custom function to do a small check which products are in that order, and if some certain products are part of the order, to to add that supplier email addeess as a recipient to that mail that being sent about the order.
    (I don’t mind if that will be the same email or if the supplier will get a forarded mail, but I do want that the WC will do the email sending and not for exampe by a 3rd party automation process or so.)

    Is there a suitable filter that I may hook into with my custom function for this?

    Thanks ??

    Saif

    (@babylon1999)

    Hello @maorb,

    The workflow is that when an order is being completed (i.e. ordered and paid)

    Paid and completed are two different things. An order is considered complete when you, as the admin, switch its status to ‘complete’. This triggers the following action ‘woocommerce_order_status_completed‘.

    If you wish to trigger an action when the order is paid, you can use ‘woocommerce_pre_payment_complete‘ instead.

    I also found this StackOverflow question that’s very similar to what you’re trying to achieve: https://stackoverflow.com/questions/73454876/how-can-i-send-custom-email-when-user-order-a-subscription-in-wordpress

    Hope this helps!

    Thread Starter maorb

    (@maorb)

    Thanks you Saif @babylon1999 for your reply.

    Yes of course paid and completed are two different things.
    But my question deals with the natural flow of sending emails by WC.
    As I understand, the WC is sending an email about an order when a new order is being done in the shop by a customer.
    That new order status is being auto set to “Pending payment” (if ordered and not paid) or to “Processing” (if it was also successfully paid).

    In this point an email is being sent to shop owner by WC.
    What action/filter is being trigered during this point, in the process of the email sending?
    I want to hook into this filter in order to check which product was in thatr order and if needed to add there a recipient email addresss to the mail that WC is sending.

    Thanks again.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @maorb

    You’re correct in your understanding of how WooCommerce handles order statuses and email notifications. When a new order is made, the status is set to “Pending Payment” if the order hasn’t been paid for, or “Processing” if payment was successful. An email notification is then sent to the store owner.

    To hook into this process, you can use the woocommerce_email_recipient_ filter. This filter is triggered during the email sending process, allowing you to modify the recipient list based on the order details.

    Additionally, you can also use the woocommerce_order_status_changed action hook. This hook is triggered each time an order status changes, including when it changes to “Pending payment” or “Processing”.

    I also found a resource where another user changed email recipients based on the selected shipping method. This could potentially help you rectify your situation: https://stackoverflow.com/questions/41977774/change-woocommerce-email-recipient-depending-on-address-woocommerce-local-pick

    Alternatively, you may try using a plugin like WooCommerce Order Status Manager. It allows you to edit core order statuses and trigger new order emails based on status changes.

    I hope this helps! Please let us know how it goes or if you need further assistance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Is there still a filter hook to add email recipient after new order completed?’ is closed to new replies.