Here are a few options you can test:
Since you can’t directly modify the parent theme’s function, you can create a new function in your child theme that calls the parent theme’s function and then modifies the result before returning it.
Here’s an example:
function my_bank_payment_available_fields() { // Call the parent theme's function $fields = bank_payment_available_fields(); // Remove the 'bank_name' element if (($key = array_search('bank_name', $fields)) !== false) { unset($fields[$key]); } return $fields; }
Use the Wrapper Function: Throughout your child theme, you would then call my_bank_payment_available_fields()
instead of bank_payment_available_fields()
. This new function will return the same fields as the parent theme’s function, but without the 'bank_name'
.
This approach requires you to update all the places in your child theme where you want to use this modified list of fields. If the function is used in many places, this could be tedious, but without the ability to modify the parent theme, this is one of the few options available.
Here’s a “hacky” way that might work, although it’s far from ideal:
- Create a new file in your child theme that has the same path and filename as the file that defines the original function in the parent theme.
- Copy all the contents of the original file into the new file in your child theme.
- Modify the new file to remove the
'bank_name'
from the bank_payment_available_fields
function.
- In your child theme, enqueue the new file instead of the parent file.
This approach essentially replaces the entire file from the parent theme with a modified version from the child theme. It’s not a clean or maintainable solution, as any changes to the original file in the parent theme will not be reflected in the child theme unless manually copied over.