Learn how to disable the “Process your orders on the go” mobile messaging feature in your WooCommerce order emails using a simple code snippet. Customize your email notifications safely using your child theme.
Code for Disable “Process your orders on the go”
// Process your orders on the go. Get the app" function stackfindover_disable_mobile_messaging( $mailer ) { remove_action( 'woocommerce_email_footer', array( $mailer->emails['WC_Email_New_Order'], 'mobile_messaging' ), 9 ); } add_action( 'woocommerce_email', 'stackfindover_disable_mobile_messaging' );
What Does This Code Do?
- Function Definition:
Thestackfindover_disable_mobile_messaging
function takes$mailer
(the mailer object) as an argument. Within this function, we are targeting the action that adds the mobile messaging to the email footer.
- Removing the Mobile Messaging:
Theremove_action
function is used here to remove the mobile messaging action hook from the email footer. Specifically, it targets the mobile_messaging method attached to theWC_Email_New_Order
object at priority 9.
- Hooking the Function:
Theadd_action
line hooks our custom function into WooCommerce’s email system. This means every time WooCommerce processes an email, it will execute our function and remove the unwanted mobile messaging.
Implementation Guide
1. Use an Active Child Theme
Before modifying any theme files, ensure you’re working within a child theme rather than the parent theme. This practice safeguards your customizations from being overwritten during theme updates.
2. Add the Code to Your Child Theme’s Functions File
- Locate Your Child Theme’s functions.php File:
This file is generally found in your WordPress installation under /wp-content/themes/your-child-theme/.
- Insert the Code:
Open the functions.php file and paste the code snippet at the end of the file, ensuring it is outside any other functions to prevent syntax errors.
- Save Your Changes:
After saving the file, the next new order email generated by WooCommerce will no longer include the mobile messaging [ Process Your Orders on the Go ] in the email footer.
3. Test Your Changes
After implementing the code, it’s important to trigger a test email to confirm that the mobile messaging has been removed. You can do this by:
- Placing a test order via your store’s checkout.
- Using a plugin that helps preview or resend WooCommerce email templates.