If we want to remove the bank account details from WooCommerce Thank You page, we’ll need to remove the action of the gateway, which places those details in the first place. This action is called woocommerce_thankyou_bacs
and is registered in the WC_Gateway_BACS
gateway class. To remove the action we need to get the class itself, so we can match everything the action was added with (remove_action
only removes the exact action added with add_action
).
Here is the complete example:
As you can see we get the “bacs” gateway class, store it in the $gateway
variable and use the same class to remove the Thank You page action.
Comments 7
This code does remove the bank details from the thank you page, however it also causes the bank details to be shown in the refund email, which is very confusing. Is there a fix for this?
Author
Hi Lina,
The code will not add anything to the refund email. The instructions are added to the emails by the WC core. If you want to remove the bank details from the emails, you can try adding this under the remove_action in the snippet:
remove_action( ‘woocommerce_email_before_order_table’, array( $gateway, ’email_instructions’ ), 10 );
where can i paste this code?
Author
Paste it in your “theme\functions.php” file.
Thank’s Vanbo for tutorials!
Thanks so much for the tutorial, is there a way to just remove the Bank Details but the Instruction content remains on the Thank you Page?
Author
Yes, you can do that. Just use the ‘woocommerce_bacs_accounts’ filter and return an empty array.