如何覆盖woocomerce/includes文件夹中的函数?
我已经看了一遍,但找不到特定函数的挂钩/过滤器(类wc-form-handler.php中的save_account_details)。显然,编辑该文件本身也可以,但我必须在每次更新时都这样做。
有没有办法避免每次wooccommerce更新都要重做更改?
查看WC_Form_Handler的源代码。我看到这个:
add_action( 'template_redirect', array( __CLASS__, 'save_account_details' ) );
所以,你应该能够用相反的方法去除这个:
remove_action( 'template_redirect', array( 'WC_Form_Handler', 'save_account_details' ) );
并添加您自己的功能:
add_action( 'template_redirect', 'my_function' );
或者类似的东西。
希望对有所帮助