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?
- Is there a hook that runs after a user logs in?
- How to enqueue scripts on custom post add/edit pages?
- Difference between do_action and add_action
- WooCommerce: change display order of product short description and price [closed]
- Why do some hooks not work inside class context?
- Difference between after_setup_theme and init action hooks?
- Trigger custom action when setting button pressed
- Please explain how these hooks work
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Hook after image is uploaded and image sizes generated
- add_action(‘wp_ajax_[action name]’, myfunction) problem
- WordPress Multisite: Adding actions to only one site
- trigger save_post event programmatically
- Implementing advanced add_* function wrappers
- Adding onload to body
- My add_action (wp_footer, ‘method’) is not calling?
- What is the earliest possible hook for safely using `is_front_page`?
- How to check if which hook triggered the call to a function?
- Send data to 3rd party api with wp_remote_post on wp_login
- is it possible to get the hook name in add_action?
- Run javascript code after wp_login hook?
- Difference between hooks Plugin_loaded and admin_int?
- Redirect logged in users if they are on a specific page
- admin_post hook not called
- Check if action hook exists before adding actions to it
- Hooks are not executing
- How to debug removal of rewrite rule flushing?
- after login that will redirect user role into a page
- add_action on inherit post status
- 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]
- How to pass arguments to add_action() [duplicate]
- action lifecycle
- How to use the post_updated hook before and after arguments
- Is there a recover_post hook to go with trash_post hook?
- Redirect users on specific post category or category page
- Disable email field on WooCommerce customer account details
- WP Admin Bar frontend issue with dashicon deregister
- How can i trigger an action manually?
- WooCommerce New customer email Hook? [closed]
- How to get post ID in post_updated action hook?
- 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 best filter where to use register_block_type?
- Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?
- 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
- Why doesn’t wp_enqueue_script() work when including a JavaScript file with TEMPLATEPATH?
- Check if do_action(‘custom_action’) is hooked into?
- How to find hooks as per Just-In-Time approach?
- Can I remove WooCommerce main content hook?
- 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
- WP CLI Get all Enqueued Scripts and Styles
- Delay an action until current action is completed
- What’s hook to use immediately after a user is authentcated [duplicate]
- Which hook should I use to capture $_POST(‘password’) via profile update and password reset
- Edit WooCommerce product content based on category
- Hooking into the init action will fire it too frequently?
- Event-Driven Pattern vs MVC?
- Using hooks with extra parameters
- Implement Hooks Using Array
- Looking for a hook for post.php
- Save User Meta Email Address in Lowercase
- How to list all WC products by their attributes values?
- Save acf field data via acf/save_post before post is saved
- How do I trigger a post update within a get_posts() foreach loop?
- Hook when editing user
- WooCommerce single product page quantity description [closed]
- schedule event in class oriented plugin
- Add action hook into wp_localize_script
- Hooks are not being removed in child theme
- How to replace a function using a child theme?
- Removing parent theme action on pluggable function not working
- WooCommerce Hook: Content get’s displayed twice and not AFTER the order total
- Which action hook should I use to intercept a form upon submission?
- How do I prevent term from being created on create_term hook?
- 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
- I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]
- 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
- Woocommerce table is missing a heading–can I add it by use of a hook?