I have a problem regarding overriding the file in woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php
I have edited this file and added some other fields and changed placement order. I have tried the following locations in an attempt to use my version:
- mytheme/woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php
- mytheme/woocommerce/includes/gateways/class-wc-gateway-bacs.php
- mytheme/woocommerce/includes/bacs/class-wc-gateway-bacs.php
None of the above locations worked. In my previous job I successfully overrode some of the files in woo-commerce by placing overloads within the /templates/ folder to do the trick but this time it is more complicated.
I didn’t want to replace the original file to prevent my custom edits being overwritten when the plugin is updated.
Is there’s a way to override it?
Hi Mosak i think you are working on the wrong side. Due to extend Woocommerce payment gateways you cannot override the plugin classes working on templates but you should create your own plugin hooking your code to the filter used by woocommerce to recognize the registered payment gateways.
The class WC_My_Gateway, hypothetically, could be your customization of the original bacs class, mantaining compatibility and leaving the original bacs class active.