I’m afraid you can’t do that. Cause in browser JavaScript works on DOM. And this woocommerce_checkout_order_processed
hook will be fired before the DOM loads. So there is no way you can execute this code on firing this hook.
Now there are two solutions I got-
-
Make it Ajaxified. So you don’t need to reload the DOM and you can execute JavaScript on the DOM.
-
Second solution is relatively easy but not full proof. As far I understood there should be button by pressing that the order should be processed, right? So you can track this button activity and alert on this activity.
Related Posts:
- How to remove action hook done in a plugin from functions.php in my theme?
- Add my own function to existing WooCommerce hook
- How to know what functions are hooked to an action/filter?
- WooCommerce: change display order of product short description and price [closed]
- Please explain how these hooks work
- trigger save_post event programmatically
- Implementing advanced add_* function wrappers
- My add_action (wp_footer, ‘method’) is not calling?
- is it possible to get the hook name in add_action?
- admin_post hook not called
- Check if action hook exists before adding actions to it
- after login that will redirect user role into a page
- Detect type of post status transition
- Create hooks based on an array of hook names?
- How to Remove a Filter from the Admin List Table?
- Hook before inserting user into database [duplicate]
- Remove action on product archive page [closed]
- Is there a recover_post hook to go with trash_post hook?
- How can i trigger an action manually?
- WooCommerce New customer email Hook? [closed]
- wp_redirect() not working on form submission with init hook
- add_action for lost_password or modify wp-login.php?action=lostpassword
- Run add_action hook if condition
- How to prevent action in ajax request, when in admin side?
- Woocommerce – Hide a Column in Cart Table
- Empty Super Cache programmatically (with ACF action) [closed]
- What is the action hook for an order that fails on frontend checkout in WooCommerce?
- How to use do_action_ref_array?
- WooCommerce – Overwrite action hook [closed]
- Admin Hook at the Login Page
- How to find hooks as per Just-In-Time approach?
- How To Make Sure That My Action Hook Executes Last
- Does update_comment_meta hook exists?
- how to determine how many and what kind of arguments are passed to hooks
- What’s hook to use immediately after a user is authentcated [duplicate]
- Edit WooCommerce product content based on category
- Save User Meta Email Address in Lowercase
- Save acf field data via acf/save_post before post is saved
- schedule event in class oriented plugin
- Hooks are not being removed in child theme
- Removing parent theme action on pluggable function not working
- Which action hook should I use to intercept a form upon submission?
- Would there be anything stopping me from removing both wp_head and wp_footer?
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- Is it possible to add the_content filter upon login?
- WordPress wp_loaded action hook
- add_action second argument missing
- admin_notices action doesn’t trigger within save_post action
- I don’t understand how add_action and do_action work in tandem. The former executes the code already…what is do_action for?
- Check if `do_action()` in WordPress returns any result
- How to cancel an action hooked to untrash_post? or any hook
- Add Different Actions To Different Page’s wp_footer
- How do I add some javascript validation to the admin interface form’s onsubmit?
- add_action hook for publish_post not working
- password_reset doesnt work
- Hook for inserting?
- dynamic add_action according to child pages (for homepage control)
- Remove action in a parent theme from the child theme
- Remove action within a class in a parent theme’s includes folder from the child theme
- Remove genesis_404 hook from genesis_loop [closed]
- Add html code in admin page
- How to access page variable inside action hook
- What hook to add at start of WordPress load
- A good hook to check authorization and redirect?
- Is there a author_update action?
- Display custom product option in admin order details
- Restrict editing of post type to list stored in user meta
- How to stop execution of a function via add_action hook?
- Can we change the hook firing sequence?
- changing genesis_before_while in new theme framework
- Rewrite the search page to use an appended slug + parameter
- Variation prices breakdown only for single product page
- How to call do_action() to pass arguments to hooked functions that take different number of args?
- remove_action not working for a function
- Parameters in woocommerce_before_add_to_cart_button hook
- do_action not working in loop
- add_action doesn’t work for my function
- How do I remove an action hook inside a class that is called by another class?
- profile_update hook does not fire from front-end
- Add HTML code before the title of the Tag page
- Check if front page within function passed to action
- Hooks with same priority number. Can one stack items returned in divs, position: absolute each with their own z-index?
- Can add_image_size be added earlier
- Change user role if it’s orders count more than
- Why does get_post() not return anything?
- Hook triggered twice in a Woocommerce single product page
- WordPress save_post hook not firing when checking if _GET[‘post’] is set
- add hook restricted only to either plugins or themes?
- Using actions, hooks and filters in a non-WordPress page
- addaction hook cause redirection problem
- Removing action from template class
- Which hook should I use for this scenario regarding the registration process and account/profile update?
- Redirect back to origin page after using get_delete_post_link()
- How to add custom checkout field in user details mail template
- How do I override the user’s input when updating a custom post type’s permalink?
- How to add a new link to the default register form’s footer links?
- admin_post hook not working
- How do I set a custom post type Category after import using wp_set_post_terms
- Add text when displying attribute with a hook on single product page
- Hooks to trigger a callback when adding, removing, rearranging or updating a widget in the widget area