• Resolved John Powell

    (@digipark)


    Trying to figure out where to hook into the private notes for orders. woocommerce_after_order_notes (and before_order) appear to be for the order notes section in checkout. What I need is to hook into when a private note is added on an order. For example, when a note is added about the order status changing, when there is a response back from the card processor, etc. Can anyone point me to the right hook?

    Thanks in advance…
    John

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi John!

    I think the hook you are looking for is add_order_note().

    You can take a look at this documentation for pointers:
    https://woocommerce.github.io/code-reference/classes/WC-Order.html#method_add_order_note

    Searching online, I found an article that has a similar topic to what you are trying to achieve:
    https://stackoverflow.com/questions/48667381/add-a-custom-order-note-programmatically-in-woocommerce-admin-order-edit-pages

    I hope this helps!

    Thread Starter John Powell

    (@digipark)

    Thanks for your reply Juan. I’d seen that very article on Stackoverflow but I think it’s for adding a note, not being triggered when a note is added by something else. What I’m trying to do is be notified or perform an action when the note count reaches a threshold. I know how to count the number of notes on an order… got that piece figured out. I just need to figure out when a new note is added so I can perform a function at that point. Does this make more sense?

    Thanks again…
    John

    André

    (@chiape)

    Hi @digipark, thanks for writing back!

    If I understood you correctly, you’ll need to create a new custom email, and then extend the WC_Email_Customer_Note class.

    https://github.com/woocommerce/woocommerce/blob/12fbfa5677a66bb0b4bc1d7af2ec2bbbcdd9f13b/includes/emails/class-wc-email-customer-note.php

    Is that correct?

    Alternatively, you can also try to use a plugin like the one below that will let you create a workflow to check for new notes in order and notify you via several different methods (Text messages, Slack, email, etc).

    https://www.ads-software.com/plugins/wunderautomation/

    Let us know how it goes! My very best!

    Thread Starter John Powell

    (@digipark)

    André,
    Thanks for your reply. I’m not trying to create a custom email, and don’t need assistance with the action I’m wanting to do. The issue is trying to find the right Woocommerce hook to perform a count of the comments for an order in progress.

    Wunderautomation looks like it has the trigger I’m looking for but I would think they are just using existing Woocommerce hooks. In their TRIGGERS section it shows this…

    Comment: Submitted, Approved, Status changed, WooCommerce order note submitted

    That’s exactly where I’m trying to hook in… when a “WooCommerce order note submitted”. Every time an order note is automatically submitted, I want this to run. For example, when an order changes status, a note is added. When a credit card is successfully processed, or when it fails, a note is added. That’s when I need to hook in… every time an order note is added by some admin process.

    Thanks…
    John

    Thread Starter John Powell

    (@digipark)

    And I think I finally found it… woocommerce_order_note_added

    Mirko P.

    (@rainfallnixfig)

    Hey @digipark,

    Action hook woocommerce_order_note_added to fire after an order note is added seems to be the right one for what you want to accomplish. You’ll find its code reference here.

    Since we do not provide support for customizations on this forum, if you do require more help with the actual coding, we’d recommend consulting a developer or one of the customization experts listed at https://woocommerce.com/customizations/.

    Cheers.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hook for (private) Order Notes’ is closed to new replies.